serejahh
serejahh

Reputation: 11

How to detect iPhone 6 plus with native API?

How to detect iPhone 6 plus with native API? (without checking a screen resolution)

Upvotes: 1

Views: 600

Answers (4)

CMash
CMash

Reputation: 2168

This is the best way to detect that it's definitely an iPhone 6 Plus (or any other iOS device):

https://github.com/InderKumarRathore/UIDevice-Hardware/blob/master/UIDevice%2BHardware.m

Upvotes: 0

Sverrisson
Sverrisson

Reputation: 18167

This will return true if iPhone 6 Plus called Retina HD 5.5 by Apple.

-(BOOL)iPhone6Plus{
    if (([UIScreen mainScreen].scale > 2.0)) return YES;
    return NO;
}

Upvotes: 0

sweepy_
sweepy_

Reputation: 1331

You can detect iPhone 6 Plus based on its native scale, using this macro:

#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_6PLUS (IS_IPHONE && [[UIScreen mainScreen] nativeScale] == 3.0f)

Upvotes: 1

Stephen Darlington
Stephen Darlington

Reputation: 52565

In general you don't need to know which device you're running on. If you need specific hardware features then you can add them to your Info.plist.

If you want to know about the screen size then the correct way of doing it is to use the new size classes feature in iOS 8. You can see more details in the "Building Adaptive Apps with UIKit" talk at WWDC.

This also allows you to do things like show a popover on an iPad or iPhone 6 and a modal view on other devices. And you don't need to worry if Apple comes out with a new screen size.

Upvotes: 3

Related Questions