我使用以下代码根据设备(iPhone5或更低版本)调整我的故事板:
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
if(UIScreenOverscanCompensationScale==1136/640){
//move to your iphone5 storyboard
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iphone5 storyboard" bundle:[NSBundle mainBundle]];
}
else{
//move to your iphone4s storyboard
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
}}代码不能工作,即使我只是放置:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iphone5 storyboard" bundle:[NSBundle mainBundle]];...it仍然可以正常加载iphone。
我把它放在下面:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{在应用委派中。这样对吗??在应用程序设置中,我选择了原始的iphone故事板
发布于 2012-09-24 00:35:32
我设法用这种方式解决了这个问题:
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 568.0){
//move to your iphone5 storyboard
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iphone5 storyboard" bundle:[NSBundle mainBundle]];
UIViewController *vc =[storyboard instantiateInitialViewController];
// Set root view controller and make windows visible
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
}
else{
//move to your iphone4s storyboard
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
UIViewController *vc =[storyboard instantiateInitialViewController];
// Set root view controller and make windows visible
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
}}发布于 2012-09-22 00:11:54
问题是:
UIScreenOverscanCompensationScale==1136/640永远不会是真的。
检查UIScreenOverscanCompensationScale正在做什么,并返回BOOL。
发布于 2012-09-23 19:55:50
是否仍在目标摘要下指定MainStoryboard?我相信这将是应用程序首先看起来的地方。
https://stackoverflow.com/questions/12534119
复制相似问题