iOS 跳轉到系統的設置界面

如果有錯誤歡迎指正。

TOUCHID_PASSCODE這個是跳轉到設置中的Touch ID與頁面界面,下面這一句代碼就行了,首先要在info里的URL Types中設置URL Schemes為prefs。

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=TOUCHID_PASSCODE"]];

這其中App-Prefs要加個App,Prefs首字母大寫小寫都能跳,不加App會報錯,錯誤是:-canOpenURL: failed for URL: "prefs:root=Bluetooth" - error: "The operation couldn’t be completed. (OSStatus error -10814.)",具體原因我不知道,如果哪位大神知道,可以告訴我,謝謝。


還有iOS10中openURL不能用了,文檔里是這樣寫的- (BOOL)openURL:(NSURL*)url NS_DEPRECATED_IOS(2_0, 10_0, "Please use openURL:options:completionHandler: instead") NS_EXTENSION_UNAVAILABLE_IOS("");要我們用openURL:options:completionHandler:方法代替,當然你繼續用openURL也不影響代碼運行,只是會有一個警告。在我們的項目中,警告多了也不好,我們要盡量不用,能消除的警告要消除掉


為什么要在Info.plist得URL types里添加URL Schemes為prefs的url呢?因為蘋果在iOS5.0后把這個系統自帶的URL Schemes刪除了


這下面是網上找的跳轉到設置其他頁面的東西,如果不全,可以自己百度搜。

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


[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=TOUCHID_PASSCODE"]];

//? ? //數組中的字典的內容就是直接跳轉的語句

//? ? ? ? //例如跳轉到照片:prefs:root=Photos

//? ? ? ? [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=Photos"]];

//? ? ? ? //跳轉系統設置根目錄中的項目使用如下的方法:

//? ? ? ? NSArray *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];

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容