英文:
How can I add a storyboard to an iOS SDK?
问题
I'm developing an iOS SDK. I'm designing a screen that will appear in some actions. But I want to design these screens in .xib or storyboard. How can I do that?
This is how I did it:
let storyBoard: UIStoryboard = UIStoryboard(name: "Test", bundle: nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "TestViewController") as! TestViewController
controller.present(newViewController, animated: true, completion: nil)
This throws the error:
Thread 1: "Could not find a storyboard named 'Test' in bundle.
英文:
I'm developing an iOS SDK. I'm designing a screen that will appear in some actions. But I want to design these screens in .xib or storyboard. How can I do that?
This is how I did it:
let storyBoard: UIStoryboard = UIStoryboard(name: "Test", bundle: nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "TestViewController") as! TestViewController
controller.present(newViewController, animated: true, completion: nil)
This throws the error:
>Thread 1: "Could not find a storyboard named 'Test' in bundle
答案1
得分: 1
storyboardBundleOrNil:
: 包含故事板文件及其相关资源的 bundle。如果指定为 nil,此方法将在当前应用的主 bundle 中查找。
如果您正在构建一个 SDK,那么您的故事板不在主 bundle 中,您需要指定 bundle:
let storyBoard: UIStoryboard = UIStoryboard(name: "Test", bundle: Bundle(for: TestViewController.self))
英文:
> storyboardBundleOrNil:
> The bundle containing the storyboard file and its related resources. If you specify nil, this method looks in the main bundle of the current application.
If you're building an SDK, then your storyboard is not on the main bundle, you have to specify the bundle:
let storyBoard: UIStoryboard = UIStoryboard(name: "Test", bundle: Bundle(for: TestViewController.self)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论