iphone - 模态视图中的导航 Controller ?

标签 iphone xcode uinavigationcontroller

我正在使用导航 Controller 。我的 RootViewController 推送了许多 View ,但它也呈现了一个模态视图。该模态视图呈现一个 tableView。所以我想做的是弄清楚我可以将导航 Controller 推送到模态视图上,然后从该模态视图中使用它来推送带有 tableView 的 View ?或者除此之外,有没有办法从模态视图实现第二个导航 Controller ?

真正的问题是我想使用从右到左的过渡来呈现带有 tableView 的 View ,这当然不适用于模态视图。

我有这样的代码,SORT OF 提供导航 Controller 使用的从右到左的转换:

NewViewController *newViewController = [[NewViewController alloc] init];
[self presentModalViewController:newViewController animated:NO];

CGSize theSize = CGSizeMake(320, 460);
newViewController.view.frame = CGRectMake(0 + theSize.width, 0 + 20, theSize.width, theSize.height);
[UIView beginAnimations:@"animationID" context:NULL];
[UIView setAnimationDuration:0.5];
newViewController.view.frame = CGRectMake(0, 0 + 20, 320, 460);
[UIView commitAnimations];
[newViewController release];

问题在于 OldViewController(调用 NewViewController 的那个)立即消失,因此 NewViewController 会在空白屏幕上转换,而不是覆盖 OldViewController。

最佳答案

以模态方式呈现 UIViewController 会创建一个全新的导航堆栈。你可以这样做:

//Create the view you want to present modally
UIViewController *modalView = [[UIViewController alloc] init];
//Create a new navigation stack and use it as the new RootViewController for it
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:modalView];
//Present the new navigation stack modally
[self presentModalViewController:nav animated:YES];
//Release
[modalView release];
[nav release];

这是可以做到的,因为 UINavigationController 是 UIViewController 的子类。加载新 View 后,您可以随心所欲地使用它(在其之上推送另一个 View ,例如 Waqas suggeste 等 UIView 动画)。

我希望我正确地回答了你的问题。如果我没有,请告诉我。

关于iphone - 模态视图中的导航 Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5556729/

相关文章:

iphone - NSDate 保留发送到释放实例的消息

iphone - objective-c - 单后台线程

iphone - 为什么这段代码运行缓慢?

ios - 如何使用自定义键盘扩展 ios 8 的自动建议 View ?

ios - TabBar 和导航 Controller

ios - NavigationController 中的 ModalViewCOntroller

ios - UITabBar 不改变色调 Xcode 9.3

xcode - 缺少用于将 core-plot 文档安装到 xCode 中的 com.CorePlot.Framework.docset 包

ios - Xcode:静态库的多个版本

iphone - 呈现 UINavigationController 多个深度 View ,作为初始 View