作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试访问移动数据/蜂窝数据设置页面,其中列出了可以访问移动/蜂窝数据或互联网的所有应用。
我尝试了下面的代码:
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!)
}
}
最佳答案
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/
我是一名优秀的程序员,十分优秀!