加载不同的 Nib 文件
我为 iPhone 和 iPad 创建了两个 nib 文件,因此我的应用程序将是通用的。
我使用这种方法来检查它是否是 iPad:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
但我不知道当它知道它是什么时如何加载正确的笔尖。
有谁知道相应地加载到 nib 文件的正确方法?
I created two nib files for the iPhone and iPad, so my app will be universal.
I use this method to check if it is an iPad:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
but I don't know how to load the proper nib when it knows which it is.
Does anyone know the correct method to load to nib file, accordingly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实际上,Apple 会自动完成所有这些工作,只需命名您的 NIB 文件:
并使用最少的代码加载您的视图控制器:
Actually, Apple does all this automatically, just name your NIB files:
and load your view controller with the smallest amount of code:
您的界面文件应该以不同的方式命名,这样类似的东西应该可以工作。
Your interface files should be named differently so something like this should work.
您应该使用初始化器
-[UIViewController initWithNibNamed:bundle:];
。在您的 SomeViewController.m 中:
You should use a initializer
-[UIViewController initWithNibNamed:bundle:];
.In your SomeViewController.m: