Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extend app for iPhone 5 - best practice

Now that Apple is about to start shipping iPhone 5's, I'm looking into extending my applications so they appear full screen on the iPhone 5. I ran my apps on the simulator, and even the ones with a UITableView extending to the bottom of the screen, the black bars appear at the top and bottom of the screen.

Here's my question: What is the best practice for extending apps for the iPhone 5?

Should I make a separate nib now for the 3.5 and 4 inch screen, or extend everything in code?

I'm trying to make this as smooth a transition as possible, so I appeal to knowledge of SO to clue me in onto what the best way is to build for both screens.

like image 404
coder Avatar asked Sep 20 '12 18:09

coder


3 Answers

Taking advantage of the full 4" screen in your apps seems to be as simple as adding a new Default image named [email protected] with size 640 x 1136. Xcode 4.5 will actually offer to do this for you automatically by adding a black image of the proper size and name to your project.

For apps that use standard UI components, such as table views, the tables are magically extended to fill the screen. I updated an app for work and it was literally this simple, with only a couple minor issues related to my own code and UI setup. But all in all, very easy.

Contrast this with another app I work on (for myself), which uses none of the standard UI components except for UIViews. To deal with both 3.5" and 4" screens, I have had to spend quite a bit of time refactoring code that needs to know screen size for various operations of the app. (The app in this case is more of a game/simulator than say, a productivity app.)

So, your mileage may vary with regard to the level of effort really required to support the 4" screen. It will depend on how complicated and "non-standard" your app is, as I have discovered.

like image 106
Mark Granoff Avatar answered Nov 11 '22 06:11

Mark Granoff


When updating an existing app for the larger-screen iphone 5, you may also find that the bottom of the screen is not "clickable". For example, if you have a toolbar along the bottom of the screen, that toolbar would be displayed correctly, but buttons would not react to the touch. If this is the case, you need to tell the app that the window is using full screen.

If you have MainWindow.xib, open it, select the window and in the attributes inspector make sure that "Full Screen at Launch" is checked.

If you don't have MainWindow.xib in your project (and most newer projects don't), then you need to add one extra line in the applicationDidFinishLaunching of your app delegate:

- (void)applicationDidFinishLaunching:(UIApplication *)application {

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

I put it in the beginning of the method. Worked like a charm.

like image 24
Aleks G Avatar answered Nov 11 '22 05:11

Aleks G


You will find this path with simulator XCode->Targets->Summary->iPhone/iPod Deployment Info( the Retina 4-inch )

You need to add a Default image with size 640 x 1136.

Apply this code in your AppDelegate file

mainWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

mainWindow.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;

You will get the main screen size of your window. one more thing whenever you want to check in your class file just add this code

if ([UIScreen mainScreen].bounds.size.height > 500.0f)

For your view controller just add one property autoresizingMask

self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;

This works fine for me.

like image 3
Nirav Jain Avatar answered Nov 11 '22 06:11

Nirav Jain