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;
}
的招數我如何克服這個問題,而從一開始就在做這個項目?請給我一些幫助。
檢查我的答案:-http://stackoverflow.com/questions/13139430/objective-c-how-detect-iphone-iphone5-and-ipad/13139561#13139561 –
@NitinGohel Gohel,問題是如何我可以定義mainWindow屏幕大小或rootView的大小嗎?我試過了,但沒有工作 – sajaz
視圖顯示的尺寸是多少?你有沒有嘗試過'navigationController.view.frame = mainWindow.bounds'? – Wain