最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Swift从应用中跳转到App Store页面,并进行评论打分
时间:2016-09-13 编辑:简简单单 来源:一聚教程网
我们常常看到市面上有很多 App,每用个一段时间就会弹出个框,问你是否要去 AppStore 上给它打个分。如果你选择是的话,就会自动打开 AppStore,并显示这个应用的首页,用户便可以在这里撰写评论并打分了。
这个其实很简单,只需要通过 UIApplication.sharedApplication().openURL() 方法打开相应应用的 App Store 链接即可。除了跳转到 App Store,openURL 还要其它许多用法,具体参考我原来写的这篇文章:Swift - 打开第三方应用,并传递参数(附常用App的URL Scheme)
1,样例效果图
当程序启动的时候会弹出消息框询问是否去评价。点击“好的”即跳转到这个应用的 AppStore 页面。
2,样例代码
链接地址的末尾是你要跳转到的应用的 appID,这个是你提交 app 时候自动生成的,也是 AppStore 中的唯一的 ID(作为演示,这里我就使用 QQ 的 appID)。
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(animated: Bool) {
//弹出消息框
let alertController = UIAlertController(title: "觉得好用的话,给我个评价吧!",
message: nil, preferredStyle: .Alert)
let cancelAction = UIAlertAction(title: "暂不评价", style: .Cancel, handler: nil)
let okAction = UIAlertAction(title: "好的", style: .Default,
handler: {
action in
self.gotoAppStore()
})
alertController.addAction(cancelAction)
alertController.addAction(okAction)
self.presentViewController(alertController, animated: true, completion: nil)
}
//跳转到应用的AppStore页页面
func gotoAppStore() {
let urlString = "itms-apps://itunes.apple.com/app/id444934666"
let url = NSURL(string: urlString)
UIApplication.sharedApplication().openURL(url!)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
相关文章
- sora软件价格介绍 02-22
- sora官网入口地址一览 02-22
- Sora生成的视频使用教程 02-22
- 《梦幻西游》元宵灯谜线索答案大全2024 02-22
- 《原神》有朋自远方来第一天通关攻略 02-22
- 《苏醒之路》四个结局达成攻略 02-22