Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added possibility to change view controllers hierarchies in stack container. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CLFContainerViewController/CLFStackContainerViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ typedef NS_ENUM(NSUInteger, CLFStackContainerPushPopDirections) {
@property (readonly, nonatomic) UIViewController *rootViewController;
@property (readonly, nonatomic) UIViewController *topViewController;

// This overrides readonly property in base class and make possible to replace view controllers hierarchies dynamically
// (similiar to UINavigationController)
@property (readwrite, nonatomic) NSArray *viewControllers;

// The default implementation uses this property to determine which
// animations to use for the pushes and pops.
//
Expand Down
21 changes: 21 additions & 0 deletions CLFContainerViewController/CLFStackContainerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,27 @@ - (UIViewController *)topViewController
}


- (void)setViewControllers:(NSArray *)controllers
{
NSAssert([controllers count] > 0, @"CLFStackContainerViewController should has at least one controller!");

NSArray *controllersToRemove = [self.viewControllers copy];

for (UIViewController *controller in controllers)
[super addViewController:controller];

[super switchToViewController:[controllers lastObject]
animated:NO
preAnimationSetup:NULL
animations:nil
animationDurations:nil
animationOptions:nil
completionBlock:^(BOOL finished) {
for (UIViewController *controller in controllersToRemove)
[super removeViewController:controller];
}];
}

- (void (^)())transitionUpPreAnimationBlock
{
return ^{
Expand Down