如何判断ios设备类型

功能函数:

[cpp]  view plain copy
  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. }  
 

 

调用:

[cpp]  view plain copy
  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];  
 

转自:http://blog.csdn.net/tangaowen/article/details/6525992

你可能感兴趣的:(ios)