【发布时间】:2019-01-28 00:22:43
【问题描述】:
我尝试过self.view.accessibilityIdentifier 和storyboard?.accessibilityAttributedLabel,它们都不包含情节提要的 id 值。那是什么?
编辑:我发现这个问题的答案已经过时,对于 swift 4 或最近的 xcode 版本没有任何意义
【问题讨论】:
标签: swift xcode storyboard
我尝试过self.view.accessibilityIdentifier 和storyboard?.accessibilityAttributedLabel,它们都不包含情节提要的 id 值。那是什么?
编辑:我发现这个问题的答案已经过时,对于 swift 4 或最近的 xcode 版本没有任何意义
【问题讨论】:
标签: swift xcode storyboard
如果您在身份检查器中将“使用 Storyboard ID”设置为“是”,则这在 ViewDidLoad 中有效:
if let str = self.restorationIdentifier {
//Do something with the View Controller's Storyboard ID
}
【讨论】:
str 声明为String! 而不是String??或者更好的是,只需 let str = self.restorationIdentifier。
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "endGame") as! EndViewController
present(vc, animated: false, completion: nil)
在身份检查器的故事板上输入您的故事板 ID,我的是“endGame”,您还需要添加一个新的可可触摸类,然后在身份检查器中您还需要在其中添加该 ViewControllers 名称。我的是 EndViewController。然后使用上面的代码。
【讨论】: