如何使用Swift以编程方式在iPhone上打开Speak Screen?

时间:2018-02-27 10:28:14

标签: swift url-scheme

有没有办法启用设置选项"说出屏幕"在iPhone上以编程方式使用Swift?

enter image description here

2 个答案:

答案 0 :(得分:0)

您只能打开设置应用

  guard let settingsUrl = URL(string: UIApplicationOpenSettingsURLString) else {
            return
        }

        if UIApplication.shared.canOpenURL(settingsUrl) {
            if #available(iOS 10.0, *) {
                UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
                    print("Settings opened: \(success)") // Prints true
                })
            } else {
                // Fallback on earlier versions
            }
        }

答案 1 :(得分:0)

您仍然可以打开设置iOS11:

if let settings = URL(string: "App-Prefs:root=General&path=ACCESSIBILITY/SPEECH"), 
UIApplication.shared.canOpenURL(settings) {
   UIApplication.shared.open(settings, options: [UIApplication.OpenExternalURLOptionsKey.universalLinksOnly : false]) { (success) in
         print("open settings: \(success)")
   }
}

another answer的设置路径不同:

App-Prefs:root=General&path=About
App-Prefs:root=General&path=ACCESSIBILITY
App-Prefs:root=AIRPLANE_MODE
App-Prefs:root=General&path=AUTOLOCK
App-Prefs:root=General&path=USAGE/CELLULAR_USAGE
App-Prefs:root=General&path=Bluetooth
App-Prefs:root=General&path=DATE_AND_TIME
App-Prefs:root=FACETIME
App-Prefs:root=General
App-Prefs:root=General&path=Keyboard
App-Prefs:root=CASTLE
App-Prefs:root=CASTLE&path=STORAGE_AND_BACKUP
App-Prefs:root=General&path=INTERNATIONAL
App-Prefs:root=LOCATION_SERVICES
App-Prefs:root=ACCOUNT_SETTINGS
App-Prefs:root=MUSIC
App-Prefs:root=MUSIC&path=EQ
App-Prefs:root=MUSIC&path=VolumeLimit
App-Prefs:root=General&path=Network
App-Prefs:root=NIKE_PLUS_IPOD
App-Prefs:root=NOTES
App-Prefs:root=NOTIFICATIONS_ID
App-Prefs:root=Phone
App-Prefs:root=Photos
App-Prefs:root=General&path=ManagedConfigurationList
App-Prefs:root=General&path=Reset
App-Prefs:root=Sounds&path=Ringtone
App-Prefs:root=Safari
App-Prefs:root=General&path=Assistant
App-Prefs:root=Sounds
App-Prefs:root=General&path=SOFTWARE_UPDATE_LINK
App-Prefs:root=STORE
App-Prefs:root=TWITTER
App-Prefs:root=General&path=USAGE
App-Prefs:root=VIDEO
App-Prefs:root=General&path=Network/VPN
App-Prefs:root=Wallpaper
App-Prefs:root=WIFI
App-Prefs:root=INTERNET_TETHERING