Xcode 6 - 没有故事板的模板
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24973521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 6 - Template without Storyboards
提问by Woodstock
I know this sounds trivial, but I'm quite irritated with the lack of an 'empty' template for iOS apps in beta 3/4.
我知道这听起来微不足道,但我对 Beta 3/4 中缺少 iOS 应用程序的“空”模板感到非常恼火。
I detest the Storyboard approach, (IMO it's naive to assume that it's always the most elegant approach).
我讨厌 Storyboard 方法,(IMO 认为它总是最优雅的方法是幼稚的)。
In fact for the majority of my use cases, Storyboards simply don't work.
事实上,对于我的大多数用例,故事板根本不起作用。
Can anyone advise me on how I can take the empty template and get to a starting point (app delegate with a window) without SB's? - or migrate one of the other templates to non SB.
谁能告诉我如何在没有 SB 的情况下使用空模板并到达起点(带有窗口的应用程序委托)?- 或将其他模板之一迁移到非 SB。
that prepare for segue method gives me shivers it's so ugly...
为 segue 做准备的方法让我不寒而栗,它是如此丑陋......
Thanks in advance.
提前致谢。
回答by CodingMeSwiftly
I don't like Storyboards either.
我也不喜欢故事板。
Here is what I do to go from a SB-template to nice and clean 'from code design':
这是我从 SB 模板到“从代码设计”到漂亮干净的方法:
- create a project from the single-view template (gives you the least storyboard 'boilerplaite')
- delete the Storyboard
go to your AppDelegate(.m / .swift) and create a
UIWindow
through code inapplication:didFinishLaunchingWithOptions:
:CGRect screenBounds = [[UIScreen mainScreen] bounds]; UIWindow *window = [[UIWindow alloc] initWithFrame:screenBounds]; UIViewController *viewController = [[UIViewController alloc] init]; [window setRootViewController:viewController]; [window makeKeyAndVisible]; [self setWindow:window];
remember to go select your target and delete the 'MainInterface' entry in 'General' under 'Deployment Info'
- 从单视图模板创建一个项目(为您提供最少的故事板“boilerplaite”)
- 删除故事板
转到您的 AppDelegate(.m / .swift) 并
UIWindow
在application:didFinishLaunchingWithOptions:
以下位置创建一个直通代码:CGRect screenBounds = [[UIScreen mainScreen] bounds]; UIWindow *window = [[UIWindow alloc] initWithFrame:screenBounds]; UIViewController *viewController = [[UIViewController alloc] init]; [window setRootViewController:viewController]; [window makeKeyAndVisible]; [self setWindow:window];
记得去选择你的目标并删除“部署信息”下“常规”中的“主界面”条目
From this point on, you are ready to go and Xcode won't annoy you with SB anymore :)
从现在开始,您就可以开始使用了,Xcode 不会再用 SB 惹恼您了 :)
Unfortunately, I haven't found a way to save a project as a template so far :/
不幸的是,到目前为止,我还没有找到将项目另存为模板的方法:/
回答by Masa
You probably don't want to just delete the file without telling the rest of the project..
您可能不想只删除文件而不告诉项目的其余部分。
You want to edit the plist and remove:
您要编辑 plist 并删除:
- launch screen interface file base name
- main storyboard file base name
- 启动屏幕界面文件基本名称
- 主故事板文件基本名称
That way, your app isn't looking for files that aren't there.
这样,您的应用程序就不会寻找不存在的文件。
Then, add the code that Cabus says (which is just the code that Xcode used to provide in Xcode 5).
然后,添加 Cabus 所说的代码(这只是 Xcode 用于在 Xcode 5 中提供的代码)。
回答by elprup
There's a github library for xcode 7 project template without storyborad, which followed Cabus answer.
有一个没有故事板的 xcode 7 项目模板的 github 库,它遵循 Cabus 的回答。