0

I have to optimize one of my old project for iPhone 5 screen size. RootViewController DOES NOT HAVE a XIB. I tried few tricks in application didFinishLaunchingWithOptions: method. But nothing worked.

This is the code of application didFinishLaunchingWithOptions: method. ** Note: Commented lines are the tricks what I have tried

- (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;
}

How do I overcome this issue without doing the project from the beginning? Please give me some help.

smartsanja
  • 4,413
  • 9
  • 58
  • 106
  • check my answer of this:-http://stackoverflow.com/questions/13139430/objective-c-how-detect-iphone-iphone5-and-ipad/13139561#13139561 – Nitin Gohel Jul 15 '13 at 09:00
  • @NitinGohel Gohel, the issue is how can I define the mainWindow screen size or rootView's size? I tried it, but didn't work – smartsanja Jul 15 '13 at 09:04
  • What size does the view show at? Have you tried `navigationController.view.frame = mainWindow.bounds`? – Wain Jul 15 '13 at 09:08
  • @sajaz, you do not have to define mainWindow screen size, since it will automatically take care, based on device you are using.And for any other view's, if you are not hard coding view's frame and providing frame based on parent then it will work for you otherwise you have to do it manually, setting frame based on device. – Nuzhat Zari Jul 15 '13 at 09:12
  • @NuzhatZari I tried this in the rootViewController - (void)viewDidLoad { [super viewDidLoad]; if ([[UIScreen mainScreen] bounds].size.height == 568) { [self.view setFrame:CGRectMake(0, 0, 320, 568)]; } else { [self.view setFrame:CGRectMake(0, 0, 320, 480)]; } But Not working – smartsanja Jul 15 '13 at 09:20
  • @sajaz, are you using nibs or doing programmatically for creating UI? – Nuzhat Zari Jul 15 '13 at 09:23
  • If you have the views configured correctly (doesn't matter with or without xibs) you only need to add `Default-568h@2x.png` to the resources. – A-Live Jul 15 '13 at 09:34
  • @NuzhatZari Im not using a NIB. Actually thats the issue Im having. I cannot find a way to enable AutoResizing options. I tried above tricks, but nothing worked – smartsanja Jul 15 '13 at 09:35

1 Answers1

2

as far as i understand, you're in letterbox mode, all the time you have 2 black stripes, (one at top and another one at the bottom, in portrait mode), if so - A-Live is right, just add correct splashscreen 1136x640 72dpi png, named Default-568h@2x.png or just make autofix in warning about missing image.

Eugene Pinchuk
  • 546
  • 3
  • 14