制作通用 iOS 应用程序应遵循的初始步骤
我正要启动一个通用的 iOS 应用程序。我想仅使用界面生成器来制作此应用程序。
有人可以建议我如何排列这两个 nib 文件吗?每当我创建一个类时,只会创建一个 xib 文件,但我想要两个 xib 文件,一个用于 iPhone,另一个用于 iPad 应用程序,因为这是一个通用应用程序。
您还可以建议哪种方法更好,即通过界面或使用编码为这个通用应用程序制作 UI。
I am just about to start a universal iOS application. 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.
Also can you suggest which approach would be better i.e. making UI for this universal application through interface or using coding.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需将另一个 xib 文件添加到项目中即可。您可以首先复制您制作的第一个版本,或者使用空白的 xib。
为了确保在运行时加载正确的 xib,您有几个选项。我更喜欢在 UIViewController 上重载 nibName,但您也可以只调用 initWithNibName:,传递正确的 nib 名称。
如果你重载 nibName,它可能是这样的:
Just add another xib file to the project. You can start by making a copy of the first version you make, or with a blank xib.
To ensure correct xib is loaded at runtime you have a few options. I prefer to overload nibName on UIViewController, but you can also just call initWithNibName:, passing the correct nib name.
If you overload nibName, it might be something like this:
就我个人而言,我更喜欢使用 xib,因为它们的目的是“隐藏”GUI 代码,使“功能”代码整洁。而且“所见即所得”UI 设计也提高了开发速度。
至于添加 XIB...按照 TomSwift 的建议,稍后添加它们
,或者像我一样,稍后批量执行它们...即
(请注意,确保您获得所有参考更改并正确无误可能会很麻烦并备份所有内容:)
祝您好运。
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.
As for adding XIB...do As TomSwift suggest, just add them later
or as I did, do them on bulk later...i.e.
(Note making sure you get all references changes and correct can be tidious & backup everything :)
Good luck.