ios - 导航堆栈在运行时重新排序/重新安排场景

标签 ios xcode uinavigationcontroller storyboard scene

我有一个带有 UITableViewController 的导航 Controller ,我允许用户重新排序单元格。假设用户最终设置了单元格,如 RootViewController 所示(下图)。

如你所见indexPath.row:0指向场景4 indexPath.row:1指向场景2 indexPath.row:2指向场景3 indexPath.row:3指向场景7 indexPath.row:4指向场景1

问题:现在,当用户点击 RootViewController 导航栏上的 Next 按钮时,我希望场景以某种方式重新排列自己,堆栈变为:

场景 4 将首先出现,下一个按钮会插入场景 2。
在场景 2 中,下一个按钮会插入场景 3。
在场景 3 中,下一个按钮会插入场景 7。 在场景 7 中,下一个按钮会插入场景 1。

当用户点击后退按钮时,场景以相同的顺序弹出:场景 1 到场景 7 到场景 3 到场景 2 到场景 4 最后回到 RootViewController

我在 Xcode 4.6.3 中使用 Storyboard。为 iOS6 设计。

谢谢!

enter image description here

最佳答案

除了使用 Storyboard,您始终可以使用 Objective-C 来执行逻辑。

利用 [self pushViewController:vc];[self popViewController:vc];(甚至 [self popToRootViewController:animated:]; ), 你可以按照你决定的逻辑排列 View Controller 。

默认情况下,UINavigationController 将在您将 View Controller 推送给它后处理“返回路径”。

关于ios - 导航堆栈在运行时重新排序/重新安排场景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17289055/

相关文章:

ios - 如何在保持光标快速移动的同时隐藏键盘

iphone - 推特发帖错误

iphone - 有没有办法获取用户设备上发生的崩溃日志?

ios - 带有 NavigationBar 的 TabBar 应用程序

ios - 使用 segues 时保留 View Controller 的状态

ios - 如何在 AppDelegate 之外调用 “application didRegisterForRemoteNotificationsWithDeviceToken”

iphone - 获取数组对象的索引

ios - 需要帮助调试 Swift 2.3 应用程序。仅存档上的链接器和位码错误

iOS - View Controller 的顺序

iphone - 简单表格导航帮助