如何判断 ios设备的类型(iphone,ipod,ipad)
2013/11/20 23:25:28 苹果吧 博客园
我要评论(0)
- 摘要:功能函数:-(bool)checkDevice:(NSString*)name{NSString*deviceType=[UIDevicecurrentDevice].model;NSLog(@"deviceType=%@",deviceType);NSRangerange=[deviceTyperangeOfString:name];returnrange.location!=NSNotFound;}调用:NSString*nsStrIphone=@"iPhone"
- 标签:iphone iOS 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];