这个问题在这里已经有了答案:
Could not find a storyboard named 'Main' in bundle
(26 个回答)
5年前关闭。
我想创建一个应用程序并设置初始 View Controller 。我确实删除了 Storyboard并且不想使用它。但是,应用程序给我一个错误:
Could not find a storyboard named 'Main' in bundle NSBundle
但我确实故意删除了它。我想通过代码创建 UI。这是我的 AppDelegate:
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow(frame: UIScreen.main.bounds)
let initialViewController = SearchViewController()
self.window?.rootViewController = initialViewController
self.window?.makeKeyAndVisible()
return true
}
}
最佳答案
你有两个选择
1) 打开 Info.Plist 并删除“主 Storyboard文件基本名称”行。
2)转到目标 -> 常规选项卡 -> 部署信息 -> 主界面 -> 删除“主”并将其设置为空白字符串
关于ios - 没有 Storyboard的 Swift 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42301069/