【发布时间】:2018-12-28 16:43:16
【问题描述】:
我看到了几个与我类似的问题,但到目前为止,没有一个答案对我有用。
我有一个 TabBarController 连接到 3 个 NavigationControllers。每个 NavigationController 都有一个自定义 ViewController。请参阅下面的屏幕截图。 其中一个 ViewController 有一个 TableView。我有一个取消按钮,它通过在 IBAction 中选择另一个 selectedIndex 来退出此视图,该按钮位于此 ViewController 的自定义类中。每个单元格中都有文本字段,用户可以在其中输入文本。 但是,我希望这个取消按钮可以重置 ViewController,以便 TableView 和控制器中的所有其他内容都将重置为其原始状态。我该怎么做?
@IBAction func cancel(_ sender: Any) {
let index = (self.tabBarController as! MainTabBarController).previouslySelectedIndex!
animateToTab(tabBarController: self.tabBarController!, to: self.tabBarController!.viewControllers![index])
self.tabBarController?.selectedIndex = index
}
我看到有人回答说在我的 NavigationControllers 上使用“popToRootViewController”或“popViewController”,但这些都不起作用,可能是因为每个 NavigationController 中只有一个 ViewController。
【问题讨论】:
标签: ios swift uiviewcontroller uinavigationcontroller