gpt4 book ai didi

ios - 如何在 iOS Swift 3 中以编程方式通过移动数据设置

转载 作者:可可西里 更新时间:2023-11-01 00:57:27 26 4
gpt4 key购买 nike

我正在尝试访问移动数据/蜂窝数据设置页面,其中列出了可以访问移动/蜂窝数据或互联网的所有应用。

我尝试了下面的代码:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {


let currentCell = featuresTable.cellForRow(at: indexPath)! as! HomeTableViewCell

if(currentCell.featureName!.text == "Internet Permissions")
{
// The code to enter the mobile data settings

let url = URL(string: "App-Prefs:root=MOBILEDATA")
let app = UIApplication.shared
app.openURL(url!)

}
}

Here the Output i want:

最佳答案

It is possible.! but the standard approach is to always open your App Setting Screen which is done by below code.All the Apps like Uber,Facebook etc use the below approach.the below code is written in

swift 3此外,代码还检查 ios 版本并为所有版本完成工作,还有一点解释

if let url = URL(string: UIApplicationOpenSettingsURLString){
if #available(iOS 10.0, *){
UIApplication.shared.open(url, completionHandler: nil)
print("\n--- in ios 10 ")
} else{
UIApplication.shared.openURL(url)
print("\n--- in ios other than 10 ")
}
}

UIApplicationOpenSettingsURLString : Basically opens your app's settings, Also It shows all the Services being used by app Including Locations Services,Mobile Data, Photo Library etc...

现在将 Cocoa Keys 添加到您的应用程序中,即在 plist 文件中这是一些网址 Cocoa keys for iOS 10 , Cocoa Keys from developer.apple

希望对你有帮助

关于ios - 如何在 iOS Swift 3 中以编程方式通过移动数据设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42666712/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com