如何在Swift 3中打开WIFI设置 [英] How to open WIFI setting in Swift 3

查看:356
本文介绍了如何在Swift 3中打开WIFI设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的iOS应用程序中打开WIFI设置部分,我的代码在使用iOS 9.2的Swift 3之前运行良好

I want to open WIFI setting section from my iOS application, my code was working well before Swift 3 with iOS 9.2

if let settingsURL = URL(string: AppSettingsWifiUrl) {
    UIApplication.shared.openURL(settingsURL)
}

但是更新后,它不能在Xcode 8 + Swift 3 + iOS 10上运行,这里有人可以帮忙吗?

But after updating it is not working with Xcode 8 + Swift 3 + iOS 10, can anybody help here?

推荐答案

我们无法在iOS 11上执行此操作,我们只能打开设置:

We can't do this anymore on iOS 11, we can just open the settings :

if let url = URL(string:UIApplicationOpenSettingsURLString) {
    if UIApplication.shared.canOpenURL(url) {
       let url =  UIApplication.shared.open(url, options: [:], completionHandler: nil)
    }
}

这篇关于如何在Swift 3中打开WIFI设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆