加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iphone – 将UINavigationController添加到现有的UIViewControll

发布时间:2020-12-15 01:49:54 所属栏目:百科 来源:网络整理
导读:如何将现有的UIViewController(使用presentModalViewController呈现)添加到UINavigationController? 当用户点击按钮时,需要推送我的详细视图的新副本. (换句话说,pushViewController在UINavigationController中以模态方式显示pushViewController). 最简单的
如何将现有的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];

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读