我想用 url 打开另一个应用程序,但是应用程序打开但它不会导航到用户个人资料,即使我在代码中指定了用户 twitter 句柄。我在做什么错-这是我的代码:
@IBAction func didTapTwitterBtn() {
var twitter = "stackoverflow"
let application = UIApplication.shared
let appUrl = URL(string: "Twitter://\(twitter)")
let webUrl = URL(string: "https://twitter.com/\(twitter)")
guard let appUrl = appUrl , let webUrl = webUrl else {
return
}
if application.canOpenURL(appUrl) {
application.open(appUrl, options: [:], completionHandler: nil)
} else {
application.open(webUrl)
}
}