Updating apps for iOS 6 and iPhone 5

Categories: Objective-C

Today is new iPhone day, always fun for iOS developers. Here are a couple of my findings on updating for iOS 6.

iOS 6 Autorotation

My iPad version of MASH had rotation issues, and wasn’t registering orientation changes. First, I discovered that the shouldAutorotateToOrientation method of UIViewController had been deprecated in iOS 6, but modifying my code to use the new -(BOOL)shouldAutorotate and -(NSUInteger)supportedInterfaceOrientations methods weren’t working either.

After further investigation, I found that I had some legacy code in my app delegate from the days of [window addSubview:viewController.view]. If you have this code in your app delegate, you’ll want to be sure to update that to the newer:

window.rootViewController = viewController;

Doing this will allow your app to either pull rotation preferences from your Info.plist or allow you to set them in code using:

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window;

or using the shouldAutorotate and supportedInterfaceOrientations methods in your view controller code.

iPhone 5

Adjusting the height of your iOS apps for the new iPhone 5 can also be a temporary roadblock. Your views might look right in the iOS simulator, but you might find that buttons near the bottom of the screen aren’t tappable/responsive. This is because the view controller’s view isn’t clipping subviews. The view is likely still reading it’s frame size from the NIB, which is sized for the 3.5 inch rather than 4 inch display.

I solved this problem by setting the window frame to the main screen bounds in my app delegate’s didFinishLaunchingWithOptions method like this:

[window setFrame: [[UIScreen mainScreen] bounds]];

Those are a couple of my findings. As you test and update your apps for iPhone 5 and iOS 6, maybe these tips will come in handy. I’d be interested to know if you ran into any issues with updating apps for iPhone 5 and iOS 6, too.