ios - 在 Swift 2.3 中导航到 UIViewController

标签 ios swift swift2

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

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

这样的事情可能吗?

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

最佳答案

你可以这样:

objective-C :

self.navigationController.topViewController.restorationIdentifier

swift :

self.navigationController?.topViewController?.restorationIdentifier

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

相关文章:

ios - 在 swift 中捕获无效用户输入的异常

ios - 从 Web 服务获取数据的 Alamofire 问题

ios - 如何使用 IndexPathsForSelectedRows?

ios - 如何在 Swift 中将 Parse objectId 设置为指针?

ios - 在 iOS 设备中保存从 Web 下载的图像的最佳位置?

ios - 覆盖 iPhone 中所有设备屏幕所需的图像大小

ios - 单元格维度 rowHeight 大小

swift - 停止 dispatch_after

macos - Xcode 7 和 Swift 2.0 折射可能吗?

ios - Swift 文件 - 如何禁用所有警告?