我已经在我的Xcode项目中添加了一个子项目,并将其添加为目标依赖项。我现在想在此子项目中的情节提要中使用视图控制器。我想知道这是否可行,以及如何将视图控制器从该子项目实例化到您的主项目中。
呼唤
let storyboard = UIStoryboard(name: "Calculator", bundle: nil)
let calculatorViewController = storyboard.instantiateViewController(withIdentifier: "calculatorViewController") as! CalculatorViewController
self.present(calculatorViewController, animated: false, completion: nil)
由于“计算器”情节提要板位于子项目中,因此无法使用。我正在使用Swift 3。
最佳答案
我认为问题在于Calculator
故事板不在主捆绑包中。这是您在nil
初始化程序中为捆绑包传递UIStoryboard
时,运行时试图查找它的地方。
如果您传入了情节提要中包含的一个类的捆绑软件,可能会起作用:
let storyboard = UIStoryboard(name: "Calculator", bundle: Bundle(for: calculatorViewController.self))
关于ios - 您如何调用/使用位于子项目中的 Storyboard ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41244754/