如何判断 ios设备的类型(iphone,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];
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,携手博客园推出1Panel与Halo联合会员
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步