有人能指出我创建自定义视图控制器作为容器视图控制器的任何好例子吗?我能找到的唯一文件是UIViewController Class Reference中的几段。我觉得我需要比这更多的信息,一个示例实现会很好。谷歌几乎什么都没有发现。
我对这个方法特别感兴趣:
transitionFromViewController:toViewController:duration:options:animations:completion:
答案 0 :(得分:51)
到目前为止,我发现的最好的事情是WWDC 2011 Session Video Session 102 - Implementing UIViewController Containment。
答案 1 :(得分:37)
除了已经提及的超级加密的WWDC会话视频Session 102 - Implementing UIViewController Containment之外,Apple WWDC 2012 session on "The Evolution of View Controllers on iOS"也涵盖了此主题,示例代码是示例代码包的一部分:
这里还有一个例子: https://github.com/toolmanGitHub/stackedViewControllers
答案 2 :(得分:17)
- (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];
}
此IBAction触发两个VC之间的转换:
-(IBAction)button:(id)sender {
[self transitionFromViewController:vc1
toViewController:vc2
duration:0.5
options:UIViewAnimationOptionTransitionCurlDown
animations:nil
completion:nil];
}
答案 3 :(得分:11)
我发现这个例子对我很有用
http://sandmoose.com/post/35714028270/storyboards-with-custom-container-view-controllers
他们在github上有来源:
答案 4 :(得分:10)
可以这样:
http://subjective-objective-c.blogspot.com/2011/08/writing-high-quality-view-controller.html
足以满足您的需求吗?
答案 5 :(得分:8)
不知道这是否是一个“好”的例子,但你可以从https://bitbucket.org/javieralonso/jaacordeonviewcontroller/overview
获得一个免费的Container ViewController这是一个完整的手风琴隐喻容器视图控制器
答案 6 :(得分:3)
这些是我最喜欢的(iOS7就绪)教程/关于这个主题的例子(这三个都在github上提供了源代码):
Custom Container View Controller Transitions
Interactive Custom Container View Controller Transitions
然后,当然,Apple提供了关于这个主题的全文,我发现这些内容非常宝贵: