如何判断ios设备类型

来源:互联网 发布:东莞淘宝美工专业培训 编辑:程序博客网 时间:2024/04/30 03:55

功能函数:

[cpp] view plaincopy
  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 plaincopy
  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];  
 
0 0
原创粉丝点击