Latest 1.0.6
Homepage https://github.com/brurend/ContainerViewManager
License MIT
Platforms ios 8.3, requires ARC
Authors

Version
License
Platform
Build Status

Usage

ContainerViewSegueManager

ContainerViewSegueManager is responsible for telling your UIViewController which segue it should perform.

Creating your containerView

After dropping your container into your UIViewController you should name its embedSegue identifier:

Screenshots/EmbedSegueSS.png

you also need to make sure the embed UIViewController custom class is ContainerViewSegueManager

Screenshots/ContainerViewSegueManagerSS.png

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 = [ViewDataManager class];
}
}

Make sure shouldPerformSegueWithIdentifier:sender: returns YES

-(BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender{
return YES;
}

EmptySegue

All segues from your ContainerViewSegueManager to your UIViewController should be of the type EmptySegue and have an identifier:

Screenshots/EmptySegueSS.png

ContainerDataManager

ContainerDataManager is responsible for deciding which segueIdentifier should be passed to performSegueWithIdentifier:sender: of ContainerViewSegueManager based on your application data and needs.

Subclassing ContainerDataManager

You should create a subclass of ContainerDataManager and override the additionalSetup method:

MyContainerData.h

#import <Foundation/Foundation.h>
#import <ContainerDataManager/ContainerDataManager.h>

@interface MyContainerData : ContainerDataManager

@end

Choosing which segueIdentifier will be used

ContainerDataManager additionalSetup method will be overridden by your class implementation. You MUST call [super additionalSetup] and self.currentSegueIdentifier must NOT be nil.

MyContainerData.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];
}

Swapping viewController

You can use ContainerViewSegueManager swapFromViewController:toViewController to go from one UIViewController to another UIViewController easily.

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
FirstViewController *firstView = [storyboard instantiateViewControllerWithIdentifier:@"FirstViewController"];
[ContainerViewSegueManager swapFromViewController:self toViewController:firstView];

Requirements

ContainerViewManager supports iOS 8.3+.

Installation

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.6'

Then, run the following command:

$ pod install

Author

Bruno Rendeiro, [email protected]

License

ContainerViewManager is available under the MIT license. See the License file for more info.

Latest podspec

{
    "name": "ContainerViewManager",
    "version": "1.0.6",
    "summary": "Helper classes to ContainerView usage with IE.",
    "description": "ContainerViewManager helps you with linking more than one ViewController to the same ContainerView with segues in the Interface Builder.",
    "homepage": "https://github.com/brurend/ContainerViewManager",
    "license": "MIT",
    "authors": {
        "brurend": "[email protected]"
    },
    "source": {
        "git": "https://github.com/brurend/ContainerViewManager.git",
        "tag": "1.0.6"
    },
    "platforms": {
        "ios": "8.3"
    },
    "requires_arc": true,
    "source_files": "ContainerViewManager/*"
}

Pin It on Pinterest

Share This