我正在尝试通过单击按钮打开我的 Twitter 个人资料,当我单击该按钮时它会通过 Safari 打开,但我想通过 Twitter 应用程序打开我该怎么做以及我在这里做错了什么?
let twUrl = URL(string: "twitter://user?screen_name=wixvii")!
let twUrlWeb = URL(string: "https://www.twitter.com/wixvii")!
if UIApplication.shared.canOpenURL(twUrl){
UIApplication.shared.open(twUrl, options: [:],completionHandler: nil)
}else{
UIApplication.shared.open(twUrlWeb, options: [:], completionHandler: nil)
}
最佳答案
在info.plist中加入这条命令就可以解决这个问题。
LSApplicationQueriesSchemes
关于使用操作按钮快速打开 Twitter 配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48675055/