-2
可能重複設備的iphone4s的類型和iphone5的:
Determine device (iPhone, iPod Touch) with iPhone SDK的ios如何識別
的ios如何判斷設備的類型的iPhone3GS的iphone4 iphone4s的和iphone5的?我知道[[UIScreen mainScreen]規模],但如何知道設備的類型,如iphone4和iphone5
可能重複設備的iphone4s的類型和iphone5的:
Determine device (iPhone, iPod Touch) with iPhone SDK的ios如何識別
的ios如何判斷設備的類型的iPhone3GS的iphone4 iphone4s的和iphone5的?我知道[[UIScreen mainScreen]規模],但如何知道設備的類型,如iphone4和iphone5
請按照下面的代碼,它會滿足您的需求。
#define IS_IPHONE ([[[UIDevice currentDevice] model] isEqualToString:@"iPhone"])
#define IS_IPOD ([[[UIDevice currentDevice] model] isEqualToString:@"iPod touch"])
#define IS_IPAD ([[[UIDevice currentDevice] model] isEqualToString:@"iPad"])
#define IS_IPHONE_5_SCREEN [[UIScreen mainScreen] bounds].size.height >= 568.0f && [[UIScreen mainScreen] bounds].size.height < 1024.0f
#define IS_IPHONE_4_SCREEN [[UIScreen mainScreen] bounds].size.height >= 480.0f && [[UIScreen mainScreen] bounds].size.height < 568.0f
if(IS_IPHONE_5_SCREEN)
{
if(IS_IPHONE)
NSLog(@"Hey, this is an iPhone 5 screen!");
else if(IS_IPOD)
NSLog(@"Hey, this is an iPod 5 screen!");
else
NSLog(@"Hey, this is a simulator screen with iPhone 5 screen height!");
}
else if(IS_IPHONE_4_SCREEN)
{
if(IS_IPHONE)
NSLog(@"Hey, this is a lower iPhone screen than 5!");
else if(IS_IPOD)
NSLog(@"Hey, this is a lower iPod screen than 5!");
else
NSLog(@"Hey, this is a lower simulator screen than 5!");
}
else if(IS_IPAD){
NSLog(@"Hey, this is an iPad screen!");
}
else{
NSLog(@"Hey, this is an ipad simulator screen!");
}
Enjoy!乾杯!
您可以嘗試[此鏈接] [1]。 希望這可以幫助你。 嫁的X馬斯 [1]:http://stackoverflow.com/questions/11081904/how-to-detect-ios-device-programmatically –
http://stackoverflow.com/a/ 3950748/14955看看這個鏈接。看看這個鏈接。 – MacN00b
謝謝,我認爲這個鏈接可以幫助我 – 19jk89