开发者

push uiviewcontroller from presentModalViewController

开发者 https://www.devze.com 2023-03-22 10:26 出处:网络
I Show a view using presentModalViewController. and from this UIView I want to push a UIView using UINavigationController.

I Show a view using presentModalViewController. and from this UIView I want to push a UIView using UINavigationController. I tried below code for this

[self.parentViewController.navigationController 
                pushViewController:objViewFullScreen 
                   开发者_开发问答       animated:YES];

But it did not works for me. so please can any one suggest how I push a view from ModelViewController.

Thanks


First you have to present your modal view controller inside a navigation controller:

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

[self presentModalViewController:nc animated:YES];

[vc release];
[nc release];

Then inside MyViewController you can do:

OtherViewController *vc = [[OtherViewController alloc] initWithNibName:@"MyOtherNib" bundle:nil];
[self.navigationController pushViewController:vc animated:YES];
[vc release];


-(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];
                         }
                     }];
}
0

精彩评论

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