开发者

Container View Controller Examples [closed]

开发者 https://www.devze.com 2023-04-12 15:08 出处:网络
Closed. This question is seeking recommendations for books, tools, software libraries, and more. It does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question is seeking recommendations for books, tools, software libraries, and more. It does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 7 years ago.

Improve this question

Can anyone point me to any good examples of creating a Custom View Controller as a Container View Controller? The only documentation I can find is a couple of paragraphs in the UIViewController Class Reference. I feel I need a little more information than that and an example implementation would be nice. Google has turned up nothing at all.

开发者_StackOverflow社区

I am specifically interested in the method:

transitionFromViewController:toViewController:duration:options:animations:completion:


The best thing I have found so far is the WWDC 2011 Session Video Session 102 - Implementing UIViewController Containment.


In addition to the WWDC Session Video Session 102 - Implementing UIViewController Containment that hypercrypt already mentioned, Apple WWDC 2012 session on "The Evolution of View Controllers on iOS" also covers this topic and the example code is part of the sample code package:

https://developer.apple.com/devcenter/download.action?path=/wwdc_2012/wwdc_2012_sample_code/wwdc_2012_session_code.dmg

There's also an example here: https://github.com/toolmanGitHub/stackedViewControllers


- (void)viewDidLoad{
    [super viewDidLoad];

    // I put self in a Navigation VC so we can use its right navigationbar 
    // item for triggering the transition
    self.navigationItem.rightBarButtonItem = 
     [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit 
                                                    target:self 
                                                    action:@selector(button:)] 
                                                                  autorelease];

    // create test1 and test2 instance (subclass UIViewController and 
    // also need to define their own nibs)
    vc1 = [[test1 alloc]initWithNibName:@"test1" bundle:nil];
    vc2 = [[test2 alloc]initWithNibName:@"test2" bundle:nil];

    //add to the container vc which is self    
    [self addChildViewController:vc1];
    [self addChildViewController:vc2];

    //the entry view (will be removed from it superview later by the api)
    [self.view addSubview:vc1.view];
}

this IBAction triggers the transition between two VCs:

-(IBAction)button:(id)sender {
    [self transitionFromViewController:vc1 
                      toViewController:vc2 
                              duration:0.5    
                               options:UIViewAnimationOptionTransitionCurlDown 
                            animations:nil 
                            completion:nil];
}


I found this example very useful for me

http://sandmoose.com/post/35714028270/storyboards-with-custom-container-view-controllers

And they have source on github:

https://github.com/mluton/EmbeddedSwapping


Could this:

http://subjective-objective-c.blogspot.com/2011/08/writing-high-quality-view-controller.html

Be enough for your needs?


don't know if this is a "good" example, but you can get a free Container ViewController from https://bitbucket.org/javieralonso/jaacordeonviewcontroller/overview

It's a full accordion metaphor container view controller


These are my favorite (iOS7-ready) tutorial / examples on the subject (all three have source code available on github):

View Controller Containment

Custom Container View Controller Transitions

Interactive Custom Container View Controller Transitions

And then, of course, Apple offers a whole write-up on the subject which I find invaluable:

Creating Custom Container View Controllers

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号