UIDevice 用法

上官凯歌
2023-12-01

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]; 

 类似资料: