iphone - 将 UINavigationController 添加到现有的 UIViewController

标签 iphone xcode uiviewcontroller uinavigationcontroller

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

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

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

最佳答案

如何创建模态视图 Controller ?只需将 Controller 包装到 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];

关于iphone - 将 UINavigationController 添加到现有的 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4957878/

相关文章:

ios - popToViewController 不工作

objective-c - 切换到横向 View 并使用标签栏 Controller

objective-c - UIViewController - iPad Pro 3rd 顶部和底部出现神秘空白

Php脚本无法在服务器上上传图片

iPhone - 多文本字段搜索栏

ios - 升级我的 Mac 后无法再构建 iOS 模拟器

iphone - 使用 searchBar 时隐藏后退按钮

iphone - 如何在 iOS 中画出思想泡泡

ios - 单个UIViewcontroller,如何在多个xib之间切换?

ios - xcode : storyboard does not reflect changes made in code in ViewController. swift