Software Development

Update your iOS app to support iOS 7

It's time to get your apps ready for iOS 7, and it'll take a little more effort than just compiling with the latest Xcode.

I recently updated my White Noise app to support the modern theme of iOS 7. I learned a little trick with Interface Builder about halfway into the transition that could save you a lot of time when you update your app to support iOS 7.

The first thing I noticed when compiling my app for iOS 7 is that all the views shifted up over the status bar -- that's because in iOS 7 the status bar no longer pushes your view down. If you want to manage iOS 7 and earlier versions of the OS, you'll need to handle this difference. (Auto Layout could also help, but it's not available on iOS 5, which is why I'm currently not using it.)

Open the nib file you want to update and switch the View As field to iOS 6.1 And Earlier (Figure A).

Figure A

iOS6to7app_FigA_101713.png

The layout is just like before, with the navigation bar falling under the status bar. When you switch back to View As iOS 7.0, you'll see the navigation bar now sits on top of the status bar (Figure B).

Figure B

iOS6to7app_FigB_101713.png

In order to fix this, switch over the Size inspector and move the navigation bar down 20 points, which is the height of the status bar. This will place the nav bar below the status bar on iOS 7 but will cause earlier versions of the OS to display a 20-point gap. To fix this new problem, you also need to set the iOS 6/7 Deltas for Y to -20 so that previous versions of the OS will be positioned correctly (Figure C).

Figure C

iOS6to7app_FigC_101713.png

Switch back to viewing as iOS 6.1, and you'll notice the nav bar is positioned correctly at 0 and the Delta now shows +20 (Figure D). This tells you that for iOS 7 the nav bar will be moved down 20 points. Just remember that the Delta adjusts depending on which version of iOS you're viewing. So if you're viewing iOS 6, the Delta applies to iOS 7 and vice versa.

Figure D

iOS6to7app_FigD_101713.png

That's it! A simple fix to your Interface Builder files to support iOS 7 and earlier versions of the OS. If you created your views programmatically without the use of Interface Builder, the following code snippet might be useful so you can manually position your views:

iOS6to7app_FigE_101713.png

Hopefully this trick will save you time if you're using Interface Builder and want to support previous versions of iOS. And because there have been so many changes to iOS and the user interface, you'll want to thoroughly test your app on devices running both iOS 6 and iOS 7. Good luck!

About

Todd Moore is an app developer, technology host, and published author. His most popular application, White Noise, has been downloaded by millions of sleep-deprived customers. Although his app has received critical acclaim in the press, the biggest co...

0 comments