查找 iPad 版 xib
我通过以下方式加载 xib 文件: initWithNibName
以编程方式加载。如果我设置类似: [[LoginController alloc] initWithNibName:@"LoginController" bundle:nil];
如果在 iPhone 上执行,它不应该加载 LoginController.xib
并在 iPad 上搜索 LoginController-iPad.xib
?我的代码中没有发生这种情况,我是否必须手动选择正确的代码,还是出了什么问题?
提前致谢!
I load my xib files through: initWithNibName
programatically. If I set something like: [[LoginController alloc] initWithNibName:@"LoginController" bundle:nil];
Shouldn't it load LoginController.xib
if it is executed on iPhone and search for LoginController-iPad.xib
on the iPad? This is not happening at my code, do I have to select the right one manually or is something going wrong?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,文档中没有任何内容表明“
-iPad
”是initWithNibName:
的有效类似资源的修饰符,或者initWithNibName:
完全支持修饰符。顺便说一句,
.xib
文件由 Xcode 编译为.nib
文件,因此应用程序永远不会看到.xib
。No, there is nothing in the documentation that suggests "
-iPad
" is a valid resource-like modifier forinitWithNibName:
, or thatinitWithNibName:
supports modifiers at all.BTW,
.xib
files are compiled to.nib
files by Xcode, so the application never sees a.xib
.这是一个老问题,所以当 @shaggy frog 回答这个问题时,这个命名约定可能不存在,但是 iOS如果命名正确的话,确实应该加载 iPad 特定的 xib。在这种情况下,您的命名稍有偏差,iPad 特定 xib 的正确命名方案是
请注意,它是波形符 (~),而不是破折号 (-) 和 ipad是小写的。
This is an old question, so perhaps this naming convention did not exist when @shaggy frog answered this question, but iOS should indeed load the iPad specific xib if it is named correctly. In this case your naming is slightly off, the correct naming scheme for an iPad specific xib is
Note that it's a tilde (~) instead of a dash (-) and ipad is in lowercase.