简体   繁体   English

没有故事板或xib文件的iOS Universal App

[英]iOS Universal App without storyboard or xib file

I have a question about universal app. 我有一个关于通用应用程序的问题。 My app will not have storyboards or xib file. 我的应用程序不会有故事板或xib文件。 There is possibility to write universal iPhone/iPad application without it? 没有它可以编写通用的iPhone / iPad应用程序吗? I found some tutorial how to create universal app with storyboard, but i don't want (i can't) use this feature in my project. 我找到了一些如何使用 storyboard创建通用应用程序的教程,但我不希望(我不能)在我的项目中使用此功能。

If it is possible What should i do? 如果有可能我该怎么办? If i have to made changes only in ViewControllers? 如果我只需要在ViewControllers中进行更改? I'm start to do this, i'm not changing old project so i can do anythng - what should i learn/what should i remember? 我开始这样做,我不会改变旧项目,所以我可以做任何事情 - 我应该学习什么/我应该记得什么?

I'm targeting to iOS 5. 我的目标是iOS 5。

EDIT: 编辑:

I have a screen information in resource file and my rootViewController or any other ViewController will be created in compile time, so i can't have xib file for that, i can't put button on xib with Interface Builder becouse i don't even know how many buttons i will have there. 我在资源文件中有一个屏幕信息,我的rootViewController或任何其他ViewController将在编译时创建,所以我不能有xib文件,我不能把按钮放在xib与Interface Builder因为我甚至没有我知道那里有多少按钮。 I don't know how many screens i've got till i hit run in my project. 我不知道有多少屏幕,直到我在我的项目中运行。

Not only can you write any type of iOS app without Interface Builder , it is actually much more testable and pliable. 如果没有Interface Builder ,您不仅可以编写任何类型的iOS应用程序,它实际上更加可测试和灵活。 Some auto layout tricks are difficult (not possible?) in IB style projects, as well. 在IB风格项目中,一些auto layout技巧很难(不可能?)。

There is an incredibly impressive library called Masonry that wraps the NSLayoutContraint syntax. 有一个令人印象深刻的名为Masonry库包含了NSLayoutContraint语法。 This makes it quite pleasurable to subclass views while not having to use ugly VFL or incredibly verbose NSLayoutContraint syntax (not even going to address frame setting...blech!). 这使得子类视图非常令人愉快,而不必使用丑陋的VFL或令人难以置信的详细NSLayoutContraint语法(甚至不会解决帧设置......烦恼!)。 IB style apps also promote bad software development practices and anti-patterns (just dumping everything in a view controller presentation-wise. No Separation of Concerns!). IB风格的应用程序还会促进糟糕的软件开发实践和反模式(只是在视图控制器中呈现所有内容。不需要分离关注!)。 Also, it is more difficult to work on larger teams (IMHO even small teams) while utilizing Nibs, Xibs, and Storyboards due to merge issues. 此外,由于合并问题,在使用Nib,Xib和Storyboard时,更难以在更大的团队(IMHO甚至是小团队)上工作。

On top of all of that, you gain a much deeper understanding of the classes you are working with ( UIView , UIResponder , etc.) when writing code in this manner (once again IMHO). 最重要的是,当您以这种方式编写代码时,您UIResponder深入地了解您正在使用的类( UIViewUIResponder等)(再次恕我直言)。 There is an interesting article outlining some of these issues in more detail: http://doing-it-wrong.mikeweller.com/2013/06/ios-app-architecture-and-tdd-1.html This is by no means the only article that discusses this problem. 有一篇有趣的文章更详细地概述了其中一些问题: http//doing-it-wrong.mikeweller.com/2013/06/ios-app-architecture-and-tdd-1.html这绝不是唯一讨论这个问题的文章。 Also, this will help for your app delegate: creating a universal window-based iphone app without generated xib file 此外,这将有助于您的应用程序委托: 创建一个基于窗口的通用iPhone应用程序,而不生成xib文件

This is certainly possible, I have only used storyborads once in the many apps I have published. 这当然是可能的,我在我发布的许多应用程序中只使用过一次storyborads。 As for not using XIBs, I am not sure why you would want to do that. 至于不使用XIB,我不确定你为什么要这样做。 You can lay out your views at runtime in the init method, but I feel like that is just making things unduly hard on yourself. 您可以在init方法中在运行时布置您的视图,但我觉得这只会让您自己过度努力。 You can set a XIB up for the iPad and one for the iPhone so you can tailor the UI specifically to each device. 您可以为iPad设置XIB,为iPhone设置一个XIB,这样您就可以专门为每个设备定制UI。

Perhaps if you go into a bit more detail about why you are imposing this requirement on yourself we can discuss if it si worth the effort to go down that road. 也许如果你详细了解为什么要对自己强加这个要求,我们可以讨论是否值得努力走下去。

Good Luck. 祝好运。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在iOS中的现有应用程序中找不到.xib或Storyboard文件 - .xib or storyboard file not found in existing app in ios 如何在不使用情节提要的情况下在Xcode 6上创建通用iOS应用? - How to create universal iOS app on Xcode 6 with and without using storyboard? 如何在iOS中为通用应用创建通用情节提要? - How to create a universal storyboard for universal app in iOS? 在没有生成xib文件的情况下创建基于窗口的通用iphone应用程序 - creating a universal window-based iphone app without generated xib file 如何为没有xib文件的iPhone + iPad开发通用应用程序? - How to develop an universal app for iPhone + iPad without xib files? iPhone IOS5 Storyboard,如何使用自定义.xib文件加载UIViewController? - iPhone IOS5 Storyboard, how to load a UIViewController with a custom .xib file? 将xib文件替换为App委托类中的Main.storyboard文件 - Replace xib file with Main.storyboard file in App delegate class 是否可以在launchsceen.xib或launchscreen.storyboard的imageview中将启动图像用于通用应用程序? - Is it possible to use launch image for universal app in imageview of launchsceen.xib or launchscreen.storyboard? 你可以使用适用于iPhone的MainWindow.xib和适用于iPad的Storyboard制作通用应用吗? - Can you make a universal app using both MainWindow.xib for the iPhone and Storyboard for the iPad? 通用iOS应用文件管理 - Universal iOS app file managing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM