iOS 6 - Distinguishing between iPhone 5 and other devices?
Asked Answered
S

4

6

With the announcement of the iPhone 5 and new iPods today, I'm starting work on optimizing my app to take advantage of the new, extra screen space. I've already got to the point where my app isn't "letterboxed" anymore. I know it's early, but does anyone know how I could distinguish between the new, taller devices and the old ones?

Ideally, it would be something like this:

if (device is iPhone 5 or taller iPod touch) {
    do stuff that is ideal for the taller screen
} else {
   do what I've been doing before for the smaller screen
}

Thanks! I hope everyone else is also enjoying what Apple announced today as well!

Sandell answered 13/9, 2012 at 2:54 Comment(6)
With iOS6 still under NDA, questions like this may not get answered in public settings. I suggest visiting the Apple Developer Forums.Clobber
Oh, ok. Since the GM was out, I wasn't sure if I that's still going on, but thanks. I'll go to the dev forums from now on with stuff like this.Sandell
@SlyRaskal - This is actually not iOS 6.0-specific, so it's a perfectly viable question here.Planimeter
@Brad: thanks for the clarification. Yesterday I read another thread that was speaking about the same topic on SO, and a commenter mentioned that the information was NDA, so I followed suit and reiterated what the other iOS Developer had stated. Mea culpa. I should have done more research first.Clobber
Duplicate of: https://mcmap.net/q/99634/-how-to-detect-iphone-5-widescreen-devices/…Theca
More in-depth answer here: #12696742Cothurnus
P
6

On the top of my head, you can use bounds information for the UIScreen [UIScreen mainScreen].bounds and check the height or better the ratio of the screen.

Powerful answered 13/9, 2012 at 2:58 Comment(0)
M
14
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
    CGSize result = [[UIScreen mainScreen] bounds].size;
    if(result.height == 480)
    {
        // iPhone Classic
    }
    if(result.height == 568)
    {
        // iPhone 5
    }
}

see this link for different type of checking

Manfred answered 10/10, 2012 at 4:43 Comment(0)
D
12
- (BOOL)isTall
{
    CGRect bounds = [[UIScreen mainScreen] bounds];
    CGFloat height = bounds.size.height;
    CGFloat scale = [[UIScreen mainScreen] scale];

    return (([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) && ((height * scale) >= 1136));
}
Davy answered 17/9, 2012 at 22:27 Comment(0)
P
6

On the top of my head, you can use bounds information for the UIScreen [UIScreen mainScreen].bounds and check the height or better the ratio of the screen.

Powerful answered 13/9, 2012 at 2:58 Comment(0)
J
3

For those that the screen still returns 480 instead of 568, you need to add a new launch images with the new size in the summary tab of application settings.

Jdavie answered 20/9, 2012 at 5:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.