美文网首页iOS
应用内跳转系统设置相关界面方法总结 - iOS

应用内跳转系统设置相关界面方法总结 - iOS

作者: survivorsfyh | 来源:发表于2017-09-18 16:18 被阅读8次

    在 iOS 开发中,经常会遇到有跳转至系统设置相关界面的需求,例如提示用户开启蓝牙或者 WiFi 等功能提示操作,提醒用户打开推送或者位置权限等.

    在 iOS 6之后,第三方应用需要跳转系统设置界面则需要在 URL type 中添加一个 prefs 值.

    跳转系统设置根目录中的项目使用如下方法:

    _array = @[

    @{@"系统设置":@"prefs:root=INTERNET_TETHERING"},

    @{@"WIFI设置":@"prefs:root=WIFI"},

    @{@"蓝牙设置":@"prefs:root=Bluetooth"},

    @{@"系统通知":@"prefs:root=NOTIFICATIONS_ID"},

    @{@"通用设置":@"prefs:root=General"},

    @{@"显示设置":@"prefs:root=DISPLAY&BRIGHTNESS"},

    @{@"壁纸设置":@"prefs:root=Wallpaper"},

    @{@"声音设置":@"prefs:root=Sounds"},

    @{@"隐私设置":@"prefs:root=privacy"},

    @{@"APP Store":@"prefs:root=STORE"},

    @{@"Notes":@"prefs:root=NOTES"},

    @{@"Safari":@"prefs:root=Safari"},

    @{@"Music":@"prefs:root=MUSIC"},

    @{@"photo":@"prefs:root=Photos"}

    ];

    NSURL * url = [NSURL URLWithString:[_array[index] allValues].firstObject];

    [[UIApplication sharedApplication]openURL:url];

    如果要跳转至第三方应用的设置界面中,则使用 prefs:root = boundleId 的方式. 

    注:boundleId 是第三方应用的 boundleId.

    如果需要继续向项目内层进行跳转,则可以通过添加 path 路径的方式,具体如下:

    _array = @[

    @{@"关于本机":@"prefs:root=General&path=About"},

    @{@"软件升级":@"prefs:root=General&path=SOFTWARE_UPDATE_LINK"},

    @{@"日期时间":@"prefs:root=General&path=DATE_AND_TIME"},

    @{@"Accessibility":@"prefs:root=General&path=ACCESSIBILITY"},

    @{@"键盘设置":@"prefs:root=General&path=Keyboard"},

    @{@"VPN":@"prefs:root=General&path=VPN"},

    @{@"壁纸设置":@"prefs:root=Wallpaper"},

    @{@"声音设置":@"prefs:root=Sounds"},

    @{@"隐私设置":@"prefs:root=privacy"},

    @{@"APP Store":@"prefs:root=STORE"},

    @{@"还原设置":@"prefs:root=General&path=Reset"},

    @{@"应用通知":@"prefs:root=NOTIFICATIONS_ID&path=应用的boundleId"}

    ];

    代码示例如下:

    NSURL* url = [NSURLURLWithString:@"prefs:root=privacy"];

    [[UIApplicationsharedApplication]openURL:url];

    相关文章

      网友评论

        本文标题:应用内跳转系统设置相关界面方法总结 - iOS

        本文链接:https://www.haomeiwen.com/subject/fjebsxtx.html