5

我使用presentModalViewController. 从这里UIView我想推一个UIViewusing UINavigationController。我为此尝试了以下代码

[self.parentViewController.navigationController 
                pushViewController:objViewFullScreen 
                          animated:YES];

但这对我不起作用。所以请任何人建议我如何从ModelViewController.

谢谢

4

2 回答 2

8

首先,您必须在导航控制器中展示您的模态视图控制器:

MyViewController *vc = [[MyViewController alloc] initWithNibName:@"MyNib" bundle:nil];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:vc];

[self presentModalViewController:nc animated:YES];

[vc release];
[nc release];

然后在里面MyViewController你可以做:

OtherViewController *vc = [[OtherViewController alloc] initWithNibName:@"MyOtherNib" bundle:nil];
[self.navigationController pushViewController:vc animated:YES];
[vc release];
于 2011-07-21T08:20:51.670 回答
0
-(void)pushViewControllerWithCustomAnimation:(UIViewController *)newViewController {
    newViewController.view.alpha = 0.0f;
    [self.view addSubview:newViewController.view];

    [UIView animateWithDuration:1
                     animations:^{
                         newViewController.view.alpha = 1;
                     }
                     completion:^(BOOL fin){
                         if (fin) {
                             // finally display the new viewcontroller for real
                             [self.navigationController pushViewController:newViewController animated:NO];
                         }
                     }];
}
于 2013-05-01T12:54:19.377 回答