如何组织UIViewControllers&正确使用rootViewController

时间:2012-11-13 06:32:53

标签: objective-c uiviewcontroller

更好的做法是让一个根视图控制器处理子视图控制器之间的转换,或者在必要时切换根视图控制器吗?

我们可以使用presentViewController进行自定义动画:?

1 个答案:

答案 0 :(得分:0)

  

这意味着我无法使用[presentViewController:animated:]

这是不正确的。您可以执行以下操作:

NewTestViewController *newTestController = [[NewTestViewController alloc] initForPhone];

newTestController.view.frame = CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height);
[self.view addSubview:newTestController.view];

[UIView animateWithDuration:0.3 animations:^(void){
    newTestController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
} completion:^(BOOL worked) {
    [newTestController.view removeFromSuperview];
    [self presentViewController:newTestController animated:NO completion:nil];
}];