在没有xib的情况下优化iPhone 5屏幕

时间:2013-07-15 08:59:48

标签: iphone ios objective-c cocoa-touch

我必须针对iPhone 5屏幕尺寸优化我的旧项目之一。 RootViewController没有XIB。 我在应用程序didFinishLaunchingWithOptions:方法中尝试了一些技巧。但没有任何效果。

这是应用程序的代码didFinishLaunchingWithOptions:方法。 **注意:注释行是我试过的技巧

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self createEditableCopyOfFileIfNeeded:@"ChapterInfo.plist"];



mainWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

//    [mainWindow  setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
//    [mainWindow setAutoresizesSubviews:YES];


readerDemoController = [[ReaderDemoController alloc] initWithNibName:nil bundle:nil]; // Demo controller

//    [readerDemoController.view setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
//    [readerDemoController.view setAutoresizesSubviews:YES];

navigationController = [[UINavigationController alloc] initWithRootViewController:readerDemoController];

UIImage *imgeBack = [UIImage imageNamed:@"back.png"];
mainWindow.backgroundColor = [UIColor colorWithPatternImage:imgeBack]; // Window background color

navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque; 
[navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"titlebar.png"] forBarMetrics:UIBarMetricsDefault];
navigationController.navigationBar.translucent = YES;

//    [navigationController.view setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
//    [navigationController.view setAutoresizesSubviews:YES];

mainWindow.rootViewController = navigationController; // Set the root view controller

[mainWindow makeKeyAndVisible];


return YES;
}

如果不从一开始就完成项目,我如何克服这个问题?请给我一些帮助。

1 个答案:

答案 0 :(得分:2)

据我所知,你处于信箱模式,你总是有2条黑色条纹(一个在顶部,另一个在底部,在纵向模式下), 如果是这样 - A-Live是正确的,只需添加正确的闪屏1136x640 72dpi png,名为Default-568h@2x.png,或者只是在关于丢失图像的警告中进行自动修复。