简体   繁体   English

制作通用iOS应用程序应遵循的初始步骤

[英]Initial steps to be followed for making an Universal iOS application

I am just about to start a universal iOS application. 我将要启动一个通用的iOS应用程序。 I want to make this application using interface builder only. 我只想使用界面生成器来制作此应用程序。

Can some one suggect how can I arrange the two nib files? 有人可以建议如何排列两个笔尖文件吗? Whenever I create a class only one xib file is created, but I want two xib files, one for iPhone and the other for iPad application as this a universal application. 每当我创建一个类时,都只会创建一个xib文件,但是我想要两个xib文件,一个用于iPhone,另一个用于iPad应用程序,因为这是一个通用应用程序。

Also can you suggest which approach would be better ie making UI for this universal application through interface or using coding. 您还可以建议哪种方法更好,即通过界面或使用编码为此通用应用程序创建UI。

Just add another xib file to the project. 只需将另一个xib文件添加到项目中。 You can start by making a copy of the first version you make, or with a blank xib. 您可以从制作第一个版本的副本开始,或者使用空白的xib。

To ensure correct xib is loaded at runtime you have a few options. 为了确保在运行时加载正确的xib,您有几种选择。 I prefer to overload nibName on UIViewController, but you can also just call initWithNibName:, passing the correct nib name. 我更喜欢在UIViewController上重载nibName,但是您也可以只调用initWithNibName:,传递正确的nib名称。

If you overload nibName, it might be something like this: 如果重载nibName,则可能是这样的:

- (NSString*) nibName
{
   return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? @"myphonenib" : @"mypadnib";
}

Personally given a choice, I prefer using xib, as the purpose of them is to "hide" GUI code making "function" code uncluttered..also "WYSIWYG" UI design kicks it for speed of development. 我个人可以选择xib,因为xib的目的是“隐藏” GUI代码,使“功能”代码整洁。.“ WYSIWYG” UI设计也为提高开发速度发挥了作用。

As for adding XIB...do As TomSwift suggest, just add them later 至于添加XIB ...按照TomSwift的建议,稍后再添加

or as I did, do them on bulk later...ie 或者像我一样,稍后批量处理...即

  1. develop iphone bits first 首先开发iphone位
  2. Make copy of project 复制项目
  3. Convert copy to iPad 将副本转换为iPad
  4. Rename Appdelegate & xib with your naming standard eg *iPad suffix 用您的命名标准重命名Appdelegate和xib,例如* iPad后缀
  5. Retrofit copied into your universal original. 加装版复制到通用原件中。

(Note making sure you get all references changes and correct can be tidious & backup everything :) (请注意,确保您获得所有引用更改,并且正确无误,并备份所有内容:)

Good luck. 祝好运。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM