我已经为iOS4.0开发了一个ios应用程序,这是基于application.Now的导航,我想它也支持iPhone-5我想我在检查设备版本后改变了xib,我面临的问题是xib被改变了,但它的视图高度不是changed.How如果其他人遇到这个问题,请与me.Thanks分享想法。
发布于 2012-12-10 15:11:24
将iOS 6设置为基础软件开发工具包,并使用自动布局功能来制作可以缩放所有类型屏幕的屏幕。要做到这一点,您需要使用Xcode4.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文件,并在启动时适当地加载它们。
要根据您的屏幕大小加载不同的nib文件,在您的应用程序代理中,您需要在(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屏幕设计的nib文件的名称
发布于 2013-04-09 14:10:00
在应用代理中:-
- (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;
}它有效!
https://stackoverflow.com/questions/13630851
复制相似问题