ios - 没有 Storyboard的 Swift 应用程序

标签 ios storyboard

这个问题在这里已经有了答案:





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/

相关文章:

ios - UILabel 自动收缩并在必要时使用 2 行

javascript - 如何取消Javascript中的http请求?

ios - Tableview 的委托(delegate)方法未调用

ios - 如何使用 Swift 创建底部表单样式 Model View Controller ?

iphone - 如何使用PhoneNumberFormatter类在UITextField中格式化电话号码?

ios - Swift 3 中的 AVCaptureStillImageOutput 与 AVCapturePhotoOutput

ios - 在 Storyboard中使用同一 View Controller 的多个副本

ios - 可以将 Storyboard中的导航右栏按钮与编码的按钮结合起来吗?

ios - 如何设置我的 iOS Storyboard以像 Instagram Stream 一样弹跳?

ios - 通过访问 AppDelegate 中的 Tab Bar Items 更改 Tab Bar Item Image inset