从presentModalViewController推送uiviewcontroller

发布于 2024-11-25 09:45:50 字数 394 浏览 9 评论 0原文

我使用 presentModalViewController 显示视图。从这个 UIView 中,我想使用 UINavigationController 推送 UIView。 我尝试了下面的代码

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

,但它对我不起作用。所以请有人建议我如何从 ModelViewController 推送视图。

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼眸里的那抹悲凉 2024-12-02 09:45:50

首先,您必须在导航控制器中呈现模态视图控制器:

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];

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];
是伱的 2024-12-02 09:45:50
-(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];
                         }
                     }];
}
-(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];
                         }
                     }];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文