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

相关文章

在有效期内的苹果开发者账号(类型为个人或者公司账号)。还...
Appuploader官网--IOS ipa上传发布工具,证书制作工具跨平台...
苹果在9月13号凌晨(北京时间)发布 iOS 16,该系统的设备可...
计算机图形学--OpenGL递归实现光线追踪
Xcode 14打出来的包在低版本系统运行时会崩溃,报错信息是Li...