我最近升级到Xcode 8并将我的代码转换为Swift 3.我制作的自定义键盘(扩展)在iOS 9之前工作得很好,但我面对一对夫妇在iOS的问题10.在我的应用程序中单击按钮时打开手机设置
- 自定义键盘的容器应用程序包含一个按钮,将用户定向到键盘设置添加键盘
问题:单击此按钮不工作iOS 10即用户没有定向到设置。我已经在我的项目中配置的URL方案,并已尝试下面的代码:
@IBAction func btnGetStarted(_ sender: AnyObject) {
let settingsUrl = URL(string: UIApplicationOpenSettingsURLString)
if let url = settingsUrl {
UIApplication.shared.openURL(url)
}
}
也试过:
@IBAction func btnGetStarted(_ sender: AnyObject) {
if let settingsURL = URL(string:"prefs:root=General&path=Keyboard/KEYBOARDS") {
UIApplication.shared.openURL(settingsURL)
}
}
- 自定义键盘还包含的表情符号图像。用户需要在设置中启用“允许访问”才能使用表情符号图像。如果用户未启用“允许访问”,则他不能使用表情符号图像。如果“允许访问”未启用,并且用户尝试点击表情符号,则会弹出一个通知,告诉用户转到设置并启用“允许访问”。
问题:当应用程序在iOS中运行10
代码土司的这种敬酒不弹出:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath){
let pbWrapped: UIPasteboard? = UIPasteboard.general
if let pb = pbWrapped {
if currentKeyboard == XXXXXX.emoji {
if let data = UIImagePNGRepresentation(dataEmoji[(indexPath as NSIndexPath).row]) {
pb.setData(data, forPasteboardType: "public.png")
self.makeToast(pasteMessage, duration: 3.0, position: .center)
}
}
} else {
var style = ToastStyle()
style.messageColor = UIColor.red
style.messageAlignment = .center
//style.backgroundColor = UIColor.whiteColor()
self.makeToast("To really enjoy the keyboard, please Allow Full Access in the settings application.", duration: 8.0, position: .center, title: nil, image: UIImage(named: "toast.png"), style: style, completion: nil)
}
}
我做了计算器检查出一些解决方案,但没有他们为我工作,正如我之前说过的,我的应用程序在除iOS 10以外的所有版本上工作得非常好。 请有人可以帮我吗?
http://stackoverflow.com/questions/28152526/how-do-i-open-手机设置,当按钮被点击时 - ios – Rock
@Rock正如我上面写的,我已经试过了,我的工作 – PersianBlue
@PersianBlue:你有答案,我也面临同样的问题。 – RJ168