如何判断iOS设备类型

功能函数:

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

调用:

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-12-16 20:31  激情为梦想而生  阅读(122)  评论(0编辑  收藏  举报