我正在开发一个 iOS SDK。我正在设计一个将出现在某些操作中的屏幕。但我想在 .xib 或故事板中设计这些屏幕。我该怎么做?
我是这样做的:
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’的故事板
故事板BundleOrNil: 包含故事板文件及其相关资源的包。如果您指定 nil,此方法将在当前应用程序的主包中查找。
如果您正在构建 SDK,那么您的故事板不在主包中,您必须指定包:
let storyBoard: UIStoryboard = UIStoryboard(name: "Test", bundle: Bundle(for: TestViewController.self)