如何判断 ios设备的类型(iphone,ipod,ipad)

功能函数:

  1. -(bool)checkDevice:(NSString*)name  
  2. {  
  3.     NSString* deviceType = [UIDevice currentDevice].model;  
  4.     NSLog(@"deviceType = %@", deviceType);  
  5.       
  6.     NSRange range = [deviceType rangeOfString:name];  
  7.     return range.location != NSNotFound;  
  8. }  

 

 

调用:

  1. NSString *  nsStrIphone=@"iPhone";  
  2. NSString *  nsStrIpod=@"iPod";  
  3. NSString *  nsStrIpad=@"iPad";  
  4. bool  bIsiPhone=false;  
  5. bool  bIsiPod=false;  
  6. bool  bIsiPad=false;  
  7. bIsiPhone=[self  checkDevice:nsStrIphone];  
  8. bIsiPod=[self checkDevice:nsStrIpod];  
  9. bIsiPad=[self checkDevice:nsStrIpad];  
posted @ 2013-11-20 20:39  苹果吧  阅读(1289)  评论(0编辑  收藏  举报