view - iOS 8 - Swift - Xcode 6 Beta - 在没有界面生成器的情况下工作(没有 Nib 和 Storyboard)

标签 view swift interface-builder xcode6

我一直在互联网和 Stackoverflow 中进行大量搜索。不幸的是,似乎没有太多关于新 Xcode 版本的信息,iOS 8 特别是使用 Swift 并且在没有 Interface Builder 的情况下工作。

作为起点选择的模板现在没有从空应用程序开始的选项。您拥有的最少设置是采用单 View 应用程序,它已经为您提供了 ViewController 和一个基本的 Storyboard。

我讨厌 Storyboard,也讨厌 Nib 。我想在代码中做所有事情。我试图删除 Storyboard文件,实例化窗口,设置 rootViewController 并使其可见,就像过去的美好时光一样。 ViewController 在没有 nib 和 bundle 的情况下初始化。

结果是一个带有这个错误的 SIGABRT:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Main' in bundle NSBundle </Users/[username]/Library/Developer/CoreSimulator/Devices/BC38B690-D30E-44FB-93B1-AB861D03B414/data/Containers/Bundle/Application/B6C160C8-67E1-4A74-9F81-55D097262050/blabla.app> (loaded)'

我当然希望我仍然能够在没有 Interface Builder 的情况下制作 UI。任何人都知道如何进步?我记得我能够在之前的 Xcode 6 Beta 版本中使用空应用程序。

最佳答案

在我看来,storyBoards 很棒。它们使开发周期变得简单快捷。但如果您不想要它们,您可以创建一个 Single View Application 模板。

Delete the storyBoard and Follow these steps

1) Go to Your Target

2) Deployment Info

3) Main Interface -> Delete Main and keep field empty

enter image description here

它不会加载 Storyboard或任何 View 。现在您有责任以编程方式加载 Window 并创建 rootViewControllersviews

关于view - iOS 8 - Swift - Xcode 6 Beta - 在没有界面生成器的情况下工作(没有 Nib 和 Storyboard),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25326806/

相关文章:

iphone - 创建一个带(或不带)内存的 UIButton

cocoa-touch - 如何从头开始制作标签栏应用程序

Android 效率 : long loading time problem, 大量浏览

ios - 使用draw(_ rect :) function时出现奇怪的黑角

swift - 如何查看我使用的是哪个版本的 Swift?

swift - 如何从套接字获取数据并制作 protobuf 文件?

cocoa - 如何将显示三角形的标题放在三角形的右侧?

ios - 将 "reloading"信号从一个 View 发送到另一个 View 的 UITableView 的最佳实践

java - 对在 playframework 中实现搜索功能的疑问

ios - 如何创建混合开发 Pod