Latest1.0.0
Homepagehttps://github.com/eoghain/RBSwappableContainerView
LicenseMIT
Platformsios 7.0, requires ARC
Authors

RBSwappableContainerViewController

license cocoapods platform

An implementation of Objc.IO’s Custom Container View Controller Transitions with inspiration from Michael Luton’s custom container view controllers blog post.

My goal was to allow for the swapping out of a content view while leaving my navigation controls in place in my parent UIViewController. With very little code in your main ViewController you can now have a container that changes it’s content with animations while still having nice encapsulation.

Usage

Here in the prepareForSegue: method I identify the embed segue and use it’s destinationViewController to setup my RBSwappableContainerViewController with the list of viewControllers that it will control:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"embedSwappableViewController"])
    {
        [self loadContainedViewControllers];

        RBSwappableContainerViewController * swapVC = segue.destinationViewController;

        swapVC.selectedIndex = 0;
        swapVC.delegate = self;
        swapVC.viewControllers = @[
            self.comicImageVC,
            self.comicDescVC,
            self.comicPriceTVC,
        ];

        self.swapVC = swapVC;
    }

}

And here I just change the selectedIndex to kick off the swapping animation in regards to a button press:

- (IBAction)showDetail:(id)sender
{
    self.swapVC.selectedIndex = 1;
    self.imageBtn.enabled = YES;
    self.detailBtn.enabled = NO;
    self.priceBtn.enabled = YES;
}

Example

Example of container mid-transition. The image is shrinking and fading away while the description text is fading in. All of the surrounding UI is static, Title, Buttons, Footer, are all a part of the containing UIViewController.

ScreenShot

Latest podspec

{
    "name": "RBSwappableContainerView",
    "version": "1.0.0",
    "summary": "An UIViewController to allow for swapping out the ViewControllers in a UIContainerView, with animations.",
    "homepage": "https://github.com/eoghain/RBSwappableContainerView",
    "license": "MIT",
    "screenshots": "https://raw.githubusercontent.com/eoghain/RBSwappableContainerView/master/Screenshots/TransitionAnimation.png",
    "authors": {
        "eoghain": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/eoghain/RBSwappableContainerView.git",
        "tag": "1.0.0"
    },
    "source_files": [
        "Classes",
        "Classes/*.{h,m}"
    ],
    "exclude_files": "Classes/Exclude",
    "requires_arc": true
}

Pin It on Pinterest

Share This