1.iOS開發(fā)中有的時(shí)候需要引導(dǎo)用戶打開某個(gè)權(quán)限
//音樂設(shè)置界面
NSURL *url = [NSURL URLWithString:@"prefs:root=MUSIC"];
[[UIApplication sharedApplication] openURL:url];
//墻紙?jiān)O(shè)置界面
NSURL *url = [NSURL URLWithString:@"prefs:root=Wallpaper"];
//藍(lán)牙設(shè)置界面
NSURL *url = [NSURL URLWithString:@"prefs:root=Bluetooth"];
//iCloud設(shè)置界面
NSURL *url = [NSURL URLWithString:@"prefs:root=CASTLE"];
//更多
About — prefs:root=General&path=About
Accessibility — prefs:root=General&path=ACCESSIBILITY
Airplane Mode On — prefs:root=AIRPLANE_MODE
Auto-Lock — prefs:root=General&path=AUTOLOCK
Brightness — prefs:root=Brightness
Bluetooth — prefs:root=General&path=Bluetooth
Date & Time — prefs:root=General&path=DATE_AND_TIME
FaceTime — prefs:root=FACETIME
General — prefs:root=General
Keyboard — prefs:root=General&path=Keyboard
iCloud — prefs:root=CASTLE
iCloud Storage & Backup — prefs:root=CASTLE&path=STORAGE_AND_BACKUP
International — prefs:root=General&path=INTERNATIONAL
Location Services — prefs:root=LOCATION_SERVICES
Music — prefs:root=MUSIC
Music Equalizer — prefs:root=MUSIC&path=EQ
Music Volume Limit — prefs:root=MUSIC&path=VolumeLimit
Network — prefs:root=General&path=Network
Nike + iPod — prefs:root=NIKE_PLUS_IPOD
Notes — prefs:root=NOTES
Notification — prefs:root=NOTIFICATIONS_ID
Phone — prefs:root=Phone
Photos — prefs:root=Photos
Profile — prefs:root=General&path=ManagedConfigurationList
Reset — prefs:root=General&path=Reset
Safari — prefs:root=Safari
Siri — prefs:root=General&path=Assistant
Sounds — prefs:root=Sounds
Software Update — prefs:root=General&path=SOFTWARE_UPDATE_LINK
Store — prefs:root=STORE
Twitter — prefs:root=TWITTER
Usage — prefs:root=General&path=USAGE
VPN — prefs:root=General&path=Network/VPN
Wallpaper — prefs:root=Wallpaper
Wi-Fi — prefs:root=WIFI
2. 應(yīng)用間相互跳轉(zhuǎn)簡(jiǎn)介
在iOS開發(fā)的過程中趟大,我們經(jīng)常會(huì)遇到需要從一個(gè)應(yīng)用程序A跳轉(zhuǎn)到另一個(gè)應(yīng)用程序B的場(chǎng)景。這就需要我們掌握iOS應(yīng)用程序之間的相互跳轉(zhuǎn)知識(shí)逢防。iOS9之后膀息,應(yīng)用間跳轉(zhuǎn)需要在Info.plsit中設(shè)置白名單芦劣。以‘LSApplicationQueriesSchemes’為Key值,對(duì)應(yīng)數(shù)組value中添加白名單應(yīng)用的URL Schemes即可霍殴。若未設(shè)置白名單涮帘,會(huì)報(bào)錯(cuò),值得我們注意贬芥。
原理:通過設(shè)置跳轉(zhuǎn)到應(yīng)用B的URL Schemes(自定義的協(xié)議頭)吐辙,應(yīng)用B將其自身“綁定”到一個(gè)自定義URL Schemes上,就可以從應(yīng)用A中利用應(yīng)用B的URL Schemes啟動(dòng)應(yīng)用B了蘸劈。
設(shè)置App-B的URL Schemes
選擇項(xiàng)目App-B -> TARGETS -> Info -> URL Types -> URL Schemes昏苏,設(shè)置App-B的URL Schemes為AppB。
// 1.獲取應(yīng)用程序App-B的URL Scheme
NSURL?*appBUrl?=?[NSURL?URLWithString:@"AppB://"];
//?2.判斷手機(jī)中是否安裝了對(duì)應(yīng)程序
if?([[UIApplication?sharedApplication]?canOpenURL:appBUrl])?{
//?3.?打開應(yīng)用程序App-B
[[UIApplication?sharedApplication]?openURL:appBUrl];
}?else?{
NSLog(@"沒有安裝");
}