Ios iphone6的不同故事板
我正在配置我的应用程序,以便为不同的iPhone使用不同的故事板Ios iphone6的不同故事板,ios,iphone,xcode,ios7,Ios,Iphone,Xcode,Ios7,我正在配置我的应用程序,以便为不同的iPhone使用不同的故事板 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size; if ([UIDevice currentDevice].userInte
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
{
if (iOSDeviceScreenSize.height == 480)
{
// Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone35
UIStoryboard *iPhone35Storyboard = [UIStoryboard storyboardWithName:@"Storyboard_4S" bundle:nil];
// Instantiate the initial view controller object from the storyboard
UIViewController *initialViewController = [iPhone35Storyboard instantiateInitialViewController];
// Instantiate a UIWindow object and initialize it with the screen size of the iOS device
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Set the initial view controller to be the root view controller of the window object
self.window.rootViewController = initialViewController;
// Set the window object to be the key window and show it
[self.window makeKeyAndVisible];
}
//Not working for iPhone 6 resolution.
if(iOSDeviceScreenSize.height == 667 )
{
UIStoryboard *iphone6Storyboard=[UIStoryboard storyboardWithName:@"Storyboard_Iphone6" bundle:nil];
UIViewController *initialViewController= [iphone6Storyboard instantiateInitialViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = initialViewController;
[self.window makeKeyAndVisible];
}
}
return YES;
}
这段代码在iPhone4模拟器上运行良好,但在iPhone6模拟器上却无法运行。一切似乎都很好,但我想不出问题所在。它没有检测到iPhone 6的屏幕分辨率。请任何人帮助我。您的应用程序可能正在按比例放大模式运行,因为您尚未添加对大型手机的支持。如果是这样的话,iphone6的屏幕高度将报告为568点,而不是667点 下面是一个SO答案,解释如何正确添加对大型手机的支持: 试试这个。此代码将帮助您确定当前正在运行的模拟器或设备。要获得完整的参考,您可以使用此git hub链接
如果记录
iOSDeviceScreenSize
值,您会看到什么?ui设备硬件-确定正在使用的iOS设备:
- (NSString *)platformString
{
NSString *platform = [self platform];
if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1G";
if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS";
if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4";
if ([platform isEqualToString:@"iPhone3,3"]) return @"Verizon iPhone 4";
if ([platform isEqualToString:@"iPhone4,1"]) return @"iPhone 4S";
if ([platform isEqualToString:@"iPhone5,1"]) return @"iPhone 5 (GSM)";
if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone 5 (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone5,3"]) return @"iPhone 5c (GSM)";
if ([platform isEqualToString:@"iPhone5,4"]) return @"iPhone 5c (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone6,1"]) return @"iPhone 5s (GSM)";
if ([platform isEqualToString:@"iPhone6,2"]) return @"iPhone 5s (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone7,1"]) return @"iPhone 6 Plus";
if ([platform isEqualToString:@"iPhone7,2"]) return @"iPhone 6";
if ([platform isEqualToString:@"x86_64"]) return @"Simulator";
return platform;
}