在每個app中的設(shè)置頁面都希望能夠很方便的讓用戶開啟/關(guān)閉消息提醒象踊。方便用戶體驗。
主要代碼
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
例子
定位服務(wù)
定位服務(wù)有很多APP都有棚壁,如果用戶關(guān)閉了定位杯矩,那么,我們在APP里面可以提示用戶打開定位服務(wù)袖外。點(diǎn)擊到設(shè)置界面設(shè)置史隆,直接跳到定位服務(wù)設(shè)置界面。代碼如下:
//定位服務(wù)設(shè)置界面
NSURL *url = [NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}
這樣就可以跳到系統(tǒng)設(shè)置的定位服務(wù)界面啦在刺!
FaceTime
//FaceTime設(shè)置界面
NSURL *url = [NSURL URLWithString:@"prefs:root=FACETIME"];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}
音樂
//音樂設(shè)置界面
NSURL *url = [NSURL URLWithString:@"prefs:root=MUSIC"];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}
墻紙設(shè)置界面
//墻紙設(shè)置界面
NSURL *url = [NSURL URLWithString:@"prefs:root=Wallpaper"];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}
藍(lán)牙設(shè)置界面
//藍(lán)牙設(shè)置界面
NSURL *url = [NSURL URLWithString:@"prefs:root=Bluetooth"];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}
iCloud設(shè)置界面
//iCloud設(shè)置界面
NSURL *url = [NSURL URLWithString:@"prefs:root=CASTLE"];
if ([[UIApplication sharedApplication] canOpenURL:url]
{
[[UIApplication sharedApplication] openURL:url];
}
還有一些其他的逆害。就不一一舉例了。
prefs:root=General&path=About
prefs:root=General&path=ACCESSIBILITY
prefs:root=AIRPLANE_MODE
prefs:root=General&path=AUTOLOCK
prefs:root=General&path=USAGE/CELLULAR_USAGE
prefs:root=Brightness
prefs:root=General&path=Bluetooth
prefs:root=General&path=DATE_AND_TIME
prefs:root=FACETIME
prefs:root=General
prefs:root=General&path=Keyboard
prefs:root=CASTLE
prefs:root=CASTLE&path=STORAGE_AND_BACKUP
prefs:root=General&path=INTERNATIONAL
prefs:root=LOCATION_SERVICES
prefs:root=ACCOUNT_SETTINGS
prefs:root=MUSIC
prefs:root=MUSIC&path=EQ
prefs:root=MUSIC&path=VolumeLimit
prefs:root=General&path=Network
prefs:root=NIKE_PLUS_IPOD
prefs:root=NOTES
prefs:root=NOTIFICATIONS_ID
prefs:root=Phone
prefs:root=Photos
prefs:root=General&path=ManagedConfigurationList
prefs:root=General&path=Reset
prefs:root=Sounds&path=Ringtone
prefs:root=Safari
prefs:root=General&path=Assistant
prefs:root=Sounds
prefs:root=General&path=SOFTWARE_UPDATE_LINK
prefs:root=STORE
prefs:root=TWITTER
prefs:root=General&path=USAGE
prefs:root=VIDEO
prefs:root=General&path=Network/VPN
prefs:root=Wallpaper
prefs:root=WIFI
prefs:root=INTERNET_TETHERING
如果你想跳轉(zhuǎn)到本app的頁面 就需要用這句蚣驼。
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];