2012-11-29 60 views
1

我已经开发iOS应用的4.0.That是基于引导的application.Now我希望它也IOS为iPhone 5支持,我想我检查设备版本后改变厦门国际银行,我现在面临的问题是厦门国际银行改变,但它的观点身高不变。如果有其他人面对这个问题,如果可能,请与我分享想法。谢谢。与iPhone 5兼容的问题

+0

我注意到一件事窗口的那大小是两个不同的设备我怎么能奶源,这两个设备上的这个程序运行。 – Mohit

+0

你尝试过使用Autolayout吗?看看我的答案... –

回答

0

设置的iOS 6为基础SDK,并使用自动排版功能,使能够扩展为所有类型的屏幕画面。你需要Xcode 4.5才能做到这一点。

开始使用自动布局在这里:
http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2
http://www.raywenderlich.com/20897/beginning-auto-layout-part-2-of-2

如果你仍然想支持的iOS 4.0,有不同的屏幕尺寸独立的.xib文件,并在适当的启动加载它们。

要根据您的屏幕尺寸加载不同的笔尖文件,在应用程序委托中,您将需要添加/替换下面的代码 - (BOOL)申请:(UIApplication的*)应用程序didFinishLaunchingWithOptions:(NSDictionary的*)launchOptions

CGRect screenBounds = [[UIScreen mainScreen] bounds]; 
if (screenBounds.size.height == 568) { 
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_4inch" bundle:nil]; 
} else { 
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; 
} 

其中ViewController_4inch是专为iPhone 5的屏幕

1

在应用程序的委托笔尖文件的名称: -

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ 



CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size; 

//----------------HERE WE SETUP FOR IPHONE 4/4s/iPod---------------------- 

if(iOSDeviceScreenSize.height == 480){ 


    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_4inch" bundle:nil]; 

    NSLog(@"iPhone 4: %f", iOSDeviceScreenSize.height); 

} 

//----------------HERE WE SETUP FOR IPHONE 5---------------------- 

if(iOSDeviceScreenSize.height == 568){ 

    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_5inch" bundle:nil]; 
    NSLog(@"iPhone 5: %f", iOSDeviceScreenSize.height); 

} 

return YES; 
} 

它的作品!!!!!!