
我用@ iphone.xib的后缀命名我的iPhone xibs,然后用.xib留下我的iPad.我读过这样做是因为有人说这对他们有用,但在我的情况下它对我不起作用!
即使我为不同的.xib文件做~ipad.xib和~iphone.xib,它仍然会加载iPhone版本!
**有没有办法完全确认它是在加载iPhone版本而不是iPad版本?
有没有办法解决这个问题,以便iPad加载iPad .xibs?**
谢谢!
- (BOol)application:(UIApplication *)application dIDFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];// OverrIDe point for customization after application launch. self.vIEwController = [[[MyVIEwController alloc] initWithNibname:@"MyVIEwController" bundle:[NSBundle mainBundle]] autorelease]; self.window.rootVIEwController = self.vIEwController; [self.window makeKeyAndVisible]; return YES;}解决方法 在我的应用程序中,我这样做.我为iPad视图创建单独的.h,.m和XIB文件,然后在AppDelegate中我只创建一个if条件,它决定它将显示哪个视图控制器. 顺便说一句.我不在XIB上使用这些后缀,我将它们命名为我想要的.
我的AppDelegate.h文件(它的一部分)
@class FirstVIEwController; @class FirstIpadVIEwController; ....... ....... @property (nonatomic,retain) IBOutlet FirstVIEwController *vIEwController; @property (nonatomic,retain) IBOutlet FirstIpadVIEwController *ipadVIEwController;
我的AppDelegate.m文件(它的一部分)
if (UI_USER_INTERFACE_IdioM() == UIUserInterfaceIdiomPhone) { self.window.rootVIEwController = self.vIEwController; [self.window makeKeyAndVisible];} else { self.window.rootVIEwController = self.ipadVIEwController; [self.window makeKeyAndVisible];} 这肯定应该这样做.只需将.h文件中的类和属性更改为您的视图控制器,您应该好好去:)
编辑
我刚刚发现了如何做到这一点.正确的命名约定是_iPhone和iPad.这与我上面发布的基本相同,只是更改是它将具有相同的.h和.m文件,但是不同的XIB.
在AppDelegate .m文件中
- (BOol)application:(UIApplication *)application dIDFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // OverrIDe point for customization after application launch. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { self.vIEwController = [[VIEwController alloc] initWithNibname:@"VIEwController_iPhone" bundle:nil]; } else { self.vIEwController = [[VIEwController alloc] initWithNibname:@"VIEwController_iPad" bundle:nil]; } self.window.rootVIEwController = self.vIEwController; [self.window makeKeyAndVisible]; return YES;} 总结 以上是内存溢出为你收集整理的ios – iPad的通用应用程序没有加载iPad .xib文件?全部内容,希望文章能够帮你解决ios – iPad的通用应用程序没有加载iPad .xib文件?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)