在 iOS 10 之前,我使用了 Valentin Sherwin 编写的方法 here .
使用 Swift 3 从自定义键盘打开包含应用程序的任何解决方法?
最佳答案
请尝试使用以下方法。 它在 xcode 8.2、swift 3.0 上运行良好
func openURL(_ url: URL) {
return
}
func openApp(_ urlstring:String) {
var responder: UIResponder? = self as UIResponder
let selector = #selector(openURL(_:))
while responder != nil {
if responder!.responds(to: selector) && responder != self {
responder!.perform(selector, with: URL(string: urlstring)!)
return
}
responder = responder?.next
}
}
// Usage
//call the method like below
// self.openApp(urlString)
// URL string need to included custom scheme.
// for example, if you created scheme name = customApp
// urlString will be "customApp://?[name]=[value]"
// self.openApp("customApp://?category=1")
关于swift - 从 Swift 3 中的自定义键盘打开包含应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39163735/