我最近升级到
Xcode 8并将我的代码转换为
Swift 3.我正在制作一个自定义键盘(扩展),它完美地运行到iOS 9,但我在iOS 10中遇到了一些问题.
>自定义键盘的容器应用程序包含一个按钮,用于将用户引导至键盘设置以添加键盘
问题:此按钮单击在iOS 10中不起作用,即用户未定向到设置.我在项目中配置了URL Schemes并尝试了以下代码:
@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中运行时,不会弹出此Toast
吐司代码:
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) } }
我确实在stackoverflow上查看了一些解决方案,但它们都没有为我工作,正如我之前所说的那样,除了iOS 10之外我的应用程序完全正常.
请有人帮帮我吗?
解决方法
Swift 3 iOS 10
let settingsUrl = NSURL(string:UIApplicationopenSettingsURLString) as! URL UIApplication.shared.open(settingsUrl,options: [:],completionHandler: nil)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。