UIDevice的简单用法

  1. //设备相关信息的获取  
  2.     NSString *strName = [[UIDevice currentDevice] name];  
  3.     NSLog(@"设备名称:%@", strName);  
  4.       
  5.     NSString *strId = [[UIDevice currentDevice] uniqueIdentifier];  
  6.     NSLog(@"设备唯一标识:%@", strId);  
  7.       
  8.     NSString *strSysName = [[UIDevice currentDevice] systemName];  
  9.     NSLog(@"系统名称:%@", strSysName);  
  10.       
  11.     NSString *strSysVersion = [[UIDevice currentDevice] systemVersion];  
  12.     NSLog(@"系统版本号:%@", strSysVersion); 
  13. 判断手机系统是几的系统
  14.   if( ([[[UIDevice currentDevicesystemVersiondoubleValue]>=7.0)){

    }

  15.       
  16.     NSString *strModel = [[UIDevice currentDevice] model];  
  17.     NSLog(@"设备模式:%@", strModel);  
  18.       
  19.     NSString *strLocModel = [[UIDevice currentDevice] localizedModel];  
  20.     NSLog(@"本地设备模式:%@", strLocModel);  
  21.       
  22.     float version = [[[UIDevice currentDevice] systemVersion] floatValue];  
  23.     NSLog(@"版本号:%f\n", version);  
  24.       
  25.     //app应用相关信息的获取  
  26.     NSDictionary *dicInfo = [[NSBundle mainBundle] infoDictionary];  
  27. //    CFShow(dicInfo);  
  28.       
  29.     NSString *strAppName = [dicInfo objectForKey:@"CFBundleDisplayName"];  
  30.     NSLog(@"App应用名称:%@", strAppName);  
  31.       
  32.     NSString *strAppVersion = [dicInfo objectForKey:@"CFBundleShortVersionString"];  
  33.     NSLog(@"App应用版本:%@", strAppVersion);  
  34.       
  35.     NSString *strAppBuild = [dicInfo objectForKey:@"CFBundleVersion"];  
  36.     NSLog(@"App应用Build版本:%@", strAppBuild);  

1. 判断设备的类型ipad或者iphone,可在main中定义一个宏来记录。

    #define IS_IPAD  ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] &&[[UIDevice currentDevice] userInterfaceIdion] == UIUserInterfaceIdiomPad)

2. 调用自带应用
    调用Email
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://email邮箱地址"]]; 

    调用系统电话phone
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://88888888"]];

    调用SMS
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://888588"]];  

    调用自带浏览器Safari
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://网址"]];  

    还有:itms:// 可以打开MobileStore.app
            audio-player-event:// 可以打开iPod
            audio-player-event://?uicmd=show-purchased-playlist 可以打开iPod播放列表
            video-player-event:// 可以打开iPod中的视频

3. 禁止锁屏
    UIApplication *app = [UIApplication sharedApplication];
    app.idleTimerDisabled = YES;

4. 设置icon上的数字
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; 

Fromhttp://blog.sina.com.cn/s/blog_a263f0c601010sr9.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值