如何将现有的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];