微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

iphone – 将UINavigationController添加到现有的UIViewController

如何将现有的UIViewController(使用presentModalViewController呈现)添加到UINavigationController?

用户点击按钮时,需要推送我的详细视图的新副本. (换句话说,pushViewController在UINavigationController中以模态方式显示pushViewController).

最简单的方法来启用此功能

解决方法

你如何创建你的模态viewcontroller?只需将控制器包装到UINavigationController中

我们假设你的模态代码是这样的:

MyExampleViewController *vc = [[[MyExampleViewController alloc] initWithNibName:@"MyExample" bundle:nil] autorelease];
[self presentModalViewController:vc animated:YES];

然后将其更改为以下内容

MyExampleViewController *vc = [[[MyExampleViewController alloc] initWithNibName:@"MyExample" bundle:nil] autorelease];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease];
[self presentModalViewController:navController animated:YES];

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐