在 Swift 中从 App 启动 App Store [英] Launching App Store from App in Swift
本文介绍了在 Swift 中从 App 启动 App Store的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建一个应用程序,我有一个横幅来宣传我的另一个应用程序.这是我的代码:
I am creating an app, and I have a banner which promotes my other app. This is my code:
var barsButton : UIButton = UIButton(frame: CGRectMake((self.view.bounds.width / 2) - 51, self.view.bounds.height - 100, 102, 30))
barsButton.setImage(UIImage(named: "Bars Icon 2.png"), forState: .Normal)
barsButton.addTarget(self, action: "openBarsLink", forControlEvents: UIControlEvents.TouchUpInside)
func openBarsLink() {
var barsLink : String = "itms-apps:https://itunes.apple.com/app/bars/id706081574?mt=8"
UIApplication.sharedApplication().openURL(NSURL.URLWithString(barsLink))
}
但是,当用户按下按钮时,它只会将他们带到 App Store,而不是我的应用程序的特定页面.我做错了什么?
However, when the user presses the button, it just takes them to the App Store, and not the specific page for my app. What am I doing wrong?
推荐答案
您的 URL 中有太多协议.去掉 https:
以便 URL 读取
You have too many protocols in your URL. Get rid of https:
so the URL reads
itms-apps://itunes.apple.com/app/bars/id706081574
这篇关于在 Swift 中从 App 启动 App Store的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文