Swift:以编程方式枚举来自 UIVIewController 的传出 segues [英] Swift: programmatically enumerate outgoing segues from a UIVIewController

查看:23
本文介绍了Swift:以编程方式枚举来自 UIVIewController 的传出 segues的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想列出 UIViewController 的传出 segue,如以编程方式枚举 UIViewController 的传出 Segues,但在 Swift 中.(Swift 2、Xcode 7、iOS8+).

I want to list the outgoing segues from a UIViewController, as described in Programmatically enumerate outgoing Segues for a UIViewController, but in Swift. (Swift 2, Xcode 7, iOS8+).

我能做到

override func viewDidLoad() {
    super.viewDidLoad()
    let s = valueForKey("storyboardSegueTemplates")
    print("switchingVC: segues: \(s)") 
}

产生像

switchingVC: segues: Optional((
    "<UIStoryboardPresentationSegueTemplate: 0x1754a130>",
    "<UIStoryboardPresentationSegueTemplate: 0x17534f60>",
    "<UIStoryboardPresentationSegueTemplate: 0x17534fc0>"
))

但在那之后我很难生产任何东西.我找不到 UIStoryboardPresentationSegueTemplate 的任何定义.我怎样才能说服 Swift 告诉我里面有什么?如何找到 segue identifier?

but I struggle to produce anything after that. I can't find any definition of the UIStoryboardPresentationSegueTemplate. How can I persuade Swift to tell me what's inside it? How can I find the segue identifier?

谢谢!

推荐答案

这个 valueForKey("storyboardSegueTemplates")UNDOCUMENTED 属性和 UIStoryboardPresentationSegueTemplateUNDOCUMENTED 类.如果您要将应用程序上传到 App Store,请注意被 App Store 拒绝.

this valueForKey("storyboardSegueTemplates") is UNDOCUMENTED property and UIStoryboardPresentationSegueTemplate is UNDOCUMENTED class. Beware of rejection from App Store if you are uploading application to App Store.

如果你想在你的内部项目中使用它,使用如下

If you want to use this in your in-house projects, use as following

for template in (valueForKey("storyboardSegueTemplates") as? [AnyObject])! {
    if let identifier = template.valueForKey("identifier") as? String {
        print("identifier - " + identifier)
    }
    else {
        print("no identifier for \(template)")
    }
}

来自 https://github.com/JaviSoto/iOS9-Runtime-Headers/blob/master/Frameworks/UIKit.framework/UIStoryboardSegueTemplate.h

这篇关于Swift:以编程方式枚举来自 UIVIewController 的传出 segues的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆