OGeek|极客世界-中国程序员成长平台

标题: ios - 在 Swift 2.3 中导航到 UIViewController [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 18:06
标题: ios - 在 Swift 2.3 中导航到 UIViewController

我正在尝试使用 Swift 2.3 导航到 UIViewController。更准确地说,我正在尝试重新加载当前处于事件状态的 UIViewController。我不知道用户当前激活了哪个 View ,所以必须动态定义。

我尝试了几种方法,但它们都会导致编译或运行时错误。

这样的事情可能吗?

let activeViewIdentifier = ??? // Get currently active view identifier as a string
self.performSegueWithIdentifier(activeViewIdentifier, sender:self)



Best Answer-推荐答案


你可以这样:

objective-C :

self.navigationController.topViewController.restorationIdentifier

swift :

self.navigationController?.topViewController?.restorationIdentifier

关于ios - 在 Swift 2.3 中导航到 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40741777/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4