2013-07-15 61 views
0

我必須爲iPhone 5屏幕大小優化我的舊項目之一。 RootViewController沒有XIB。 我在應用程序didFinishLaunchingWithOptions:方法中嘗試了一些技巧。但沒有任何工作。優化iPhone 5屏幕,無需xib

這是應用程序的代碼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; 
} 

的招數我如何克服這個問題,而從一開始就在做這個項目?請給我一些幫助。

+0

檢查我的答案:-http://stackoverflow.com/questions/13139430/objective-c-how-detect-iphone-iphone5-and-ipad/13139561#13139561 –

+0

@NitinGohel Gohel,問題是如何我可以定義mainWindow屏幕大小或rootView的大小嗎?我試過了,但沒有工作 – sajaz

+0

視圖顯示的尺寸是多少?你有沒有嘗試過'navigationController.view.frame = mainWindow.bounds'? – Wain

回答

2

據我所知,你是在信箱模式,所有的時候你有2條黑色條紋,(一個在頂部,另一個在底部,在肖像模式), 如果是這樣 - 現場是正確的,只需添加正確的splashscreen 1136x640 72dpi PNG,名爲[email protected],或者只是使自動修復警告有關丟失的圖像。