如何判斷 ios設備的類型(iphone,ipod,ipad)



                                                            如何判斷 ios設備的類型(iphone,ipod,ipad)



//檢測設備

-(bool)checkDevice:(NSString*)name

{
NSString* deviceType = [UIDevice currentDevice].model;
NSLog(@"deviceType = %@", deviceType);

NSRange range = [deviceType rangeOfString:name];
return range.location != NSNotFound;

}



//此處爲調用檢測函數

NSString *  nsStrIphone=@"iPhone";
NSString *  nsStrIpod=@"iPod";
NSString *  nsStrIpad=@"iPad";
bool  bIsiPhone=false;
bool  bIsiPod=false;
bool  bIsiPad=false;
bIsiPhone=[self  checkDevice:nsStrIphone];
bIsiPod=[self checkDevice:nsStrIpod];
bIsiPad=[self checkDevice:nsStrIpad];

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章