【发布时间】:2016-10-10 17:26:35
【问题描述】:
我有两个控制器类和情节提要的 Swift Cocoa Touch 框架。当我尝试instantiateViewController 从一个班级到另一个班级时,它不起作用,它显示故事板不可见。
我可以使用以下方法从基础项目启动 test.storyboard:
if let urlString = Bundle.main.path(forResource: "testProject", ofType: "framework", inDirectory: "Frameworks") {
let bundle = (Bundle(url: NSURL(fileURLWithPath: urlString) as URL))
let sb = UIStoryboard(name: "test", bundle: bundle)
let vc = sb.instantiateViewController(withIdentifier: "TestViewcontroller")
self.show(vc, sender: nil)
}
我想在第一个按钮单击时实例化第二个视图控制器。现在我正在使用这个代码块来启动,但它不起作用。
if let urlString = Bundle.main.path(forResource: "testProject", ofType: "framework", inDirectory: "Frameworks") {
let bundle = (Bundle(url: NSURL(fileURLWithPath: urlString) as URL))
let secondvc = UIStoryboard(name: "test", bundle: bundle).instantiateViewController(withIdentifier: "secondViewc") as! secondcontroller
self.show(secondvc, sender: nil)
}
【问题讨论】:
标签: ios swift cocoa-touch