如何将故事板添加到iOS SDK中?



我正在开发一个iOS SDK。我正在设计一个屏幕,将出现在一些动作。但我想用。xib或storyboard来设计这些屏幕。我该怎么做呢?

我是这样做的:

let storyBoard: UIStoryboard = UIStoryboard(name: "Test", bundle: nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "TestViewController") as! TestViewController
controller.present(newViewController, animated: true, completion: nil)

抛出错误:

线程1:"无法在bundle

中找到名为'Test'的故事板

storyboardBundleOrNil:包含故事板文件及其相关资源的包。如果指定nil,该方法将在当前应用程序的主包中查找。

如果你正在构建一个SDK,那么你的故事板不在主bundle上,你必须指定bundle:

let storyBoard: UIStoryboard = UIStoryboard(name: "Test", bundle: Bundle(for: TestViewController.self)

最新更新