Sunday, May 15, 2011

Problem with self.window.rootViewController on iPad 3.2

Today I've needed to fix a graphical mistake in one application. The problem is that this application must work on different iOS versions and I can not use the rootViewController in the app delegate in the way:

self.window.rootViewController = self.viewController;


Finally, I found the solution doing the next.

1) Change this line in the app delegate and replace it by

[self.window addSubview:self.viewController.view];


2) Open MainWindow.xib and select the UIViewController. Check "Resize View From XIB" in the attributes inspector

3) Set the view’s frame to applicationFrame programmatically. For example:

CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
appFrame = CGRectMake(0, 20, appFrame.size.width, appFrame.size.height);

self.viewController.view.frame=appFrame;


Next time I will explain how to know which iOS version is running in our device.

Hope help!

No comments:

Post a Comment