CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✗ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Sep 2016 |
Maintained by Bruno Rendeiro.
ContainerViewSegueManager is responsible for telling your UIViewController which segue it should perform.
After dropping your container into your UIViewController you should name its embedSegue identifier:
you also need to make sure the embed UIViewController custom class is ContainerViewSegueManager
and then in your UIViewController class override prepareForSegue:sender: with references to ContainerViewSegueManager and to your ContainerDataManager subclass,
note it's VERY important that you pass your class type and not an object of it!:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"embedSegue"]) {
self.containerView = (ContainerViewSegueManager*)segue.destinationViewController;
self.containerView.containerDataClass = [CVMViewDataManager class];
}
}Make sure shouldPerformSegueWithIdentifier:sender: returns YES
-(BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender{
return YES;
}All segues from your ContainerViewSegueManager to your UIViewController should be of the type EmptySegue and have an identifier:
ContainerDataManager is responsible for deciding which segueIdentifier should be passed to performSegueWithIdentifier:sender: of ContainerViewSegueManager based on your application data and needs.
ContainerDataManager
You should create a subclass of ContainerDataManager and override the additionalSetup method:
MyContainerDataManager.h
#import <Foundation/Foundation.h>
#import <ContainerDataManager/ContainerDataManager.h>
@interface CVMViewDataManager : ContainerDataManager
@endsegueIdentifier will be usedContainerDataManager additionalSetup method will be overridden by your class implementation. You MUST call [super additionalSetup] and self.currentSegueIdentifier must NOT be nil.
MyContainerDataManager.m
-(void)additionalSetup{
_array = @[@"1",@"2"];
self.currentSegueIdentifier = @"FirstViewController";
if ([_array count] != 0) {
self.currentSegueIdentifier = @"FirstViewController";
self.parent.navigationItem.title = @"FIRST";
}
else {
self.currentSegueIdentifier = @"SecondViewController";
self.parent.navigationItem.title = @"SECOND";
}
[super additionalSetup];
}You can use ContainerViewSegueManager swapFromViewController:toViewController to go from one UIViewController to another UIViewController easily.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
CVMFirstViewController *firstView = [storyboard instantiateViewControllerWithIdentifier:@"CVMFirstViewController"];
[ContainerViewSegueManager swapFromViewController:self toViewController:firstView];ContainerViewManager supports iOS 8.3+.
ContainerViewManager is available through CocoaPods. To install
it, simply add the following line to your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.3'
pod 'ContainerViewManager', '~> 1.0.5'Then, run the following command:
$ pod installBruno Rendeiro, [email protected].
ContainerViewManager is available under the MIT license. See the License file for more info.