private func openBluetoothSettings() {
        let bluetoothURL = URL(string: "App-Prefs:Bluetooth")!
        let settingsURL = URL(string: UIApplication.openSettingsURLString)!
        
        if UIApplication.shared.canOpenURL(bluetoothURL) {
            // 尝试打开蓝牙设置
            UIApplication.shared.open(bluetoothURL, options: [:]) { success in
                if !success {
                    // 如果蓝牙页面打不开,回退到应用设置
                    UIApplication.shared.open(settingsURL, options: [:], completionHandler: nil)
                }
            }
        } else {
            // 直接打开应用设置页面
            UIApplication.shared.open(settingsURL, options: [:], completionHandler: nil)
        }
    }

 

posted on 2025-03-28 11:05  懂事长qingzZ  阅读(39)  评论(0)    收藏  举报