zoukankan      html  css  js  c++  java
  • 跳转到设置页面 与appstory

    //MARK:系统跳到应用设置页面

        func systemMySet(){

            let url = NSURL(string: UIApplicationOpenSettingsURLString)

            if let url = url where UIApplication.sharedApplication().canOpenURL(url) {

                UIApplication.sharedApplication().openURL(url)

            }

        }

    //跳转到系统设置的其他界面需要 在项目中的info中添加 URL types 添加 URL Schemes 为 prefs的url

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];

         

        //MARK:跳转到appstory

        func appStory(){

            

            //let url = "http://itunes.apple.com/lookup?id=1125895585"//只在国内的需要加cn

            let url = "http://itunes.apple.com/cn/lookup?id=1125895585"

            

            Prequest.requestJSON(.POST, URLString: url, completion: { (response) in

                // pprintLog("response:(response)")

                

                let result = (response?.objectForKey("results"))! as! NSArray

                pprintLog("result:(result)")

                

                let dic = (result.lastObject)! as! NSDictionary

                

                let lineversion = dic.objectForKey("version") as! String

                

                let infoDictionary = NSBundle.mainBundle().infoDictionary

                let localVersion : String? = infoDictionary! ["CFBundleVersion"] as? String

                

                if localVersion != lineversion{

                    

                    let alert = UIAlertController(title: "版本更新", message: "检测到有新版本,前往appstory更新", preferredStyle: UIAlertControllerStyle.Alert)

                    

                    alert.addAction(UIAlertAction(title: "取消", style: UIAlertActionStyle.Cancel) { (UIAlertAction) -> Void in

                       

                        })

                    alert.addAction(UIAlertAction(title: "确定", style: UIAlertActionStyle.Default) { (UIAlertAction) -> Void in

                       

                        //然后将 http:// 替换为 itms:// 或者 itms-apps://:

                        UIApplication.sharedApplication().openURL(NSURL(string: "http://iTunes.Apple.com/us/app/appid")!)

                        

                        })

                    self.presentViewController(alert, animated: true, completion: nil)

                    

                }

            }) { (failed) in

                pprintLog("failed:(failed)")

            }

        }

        //跳转到app评论页

        func appStoryComment(){

            let alert = UIAlertController(title: "评价应用", message: "立刻前往appstory评价", preferredStyle: UIAlertControllerStyle.Alert)

            

            alert.addAction(UIAlertAction(title: "稍后", style: UIAlertActionStyle.Cancel) { (UIAlertAction) -> Void in

           

                })

            alert.addAction(UIAlertAction(title: "确定", style: UIAlertActionStyle.Default) { (UIAlertAction) -> Void in

                let url = NSURL.init(string: "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=appid&pageNumber=0&sortOrdering=2&type=Purple+Software&mt=8")

                UIApplication.sharedApplication().openURL(url!)

                

                })

            self.presentViewController(alert, animated: true, completion: nil)

            

        }

    群号:186052819
  • 相关阅读:
    JavaScript 闭包+封装+异步同步区别
    CSS基础(三)盒子模型
    CSS基础(二)浮动
    CSS基础(一)
    HTML基础(二)
    JAVA 微信开发
    MAVEN学习总结1
    Java开发中的23种设计模式详解(转)
    navicat for mysql 10.1.7注册码
    jQuery.Validate验证库
  • 原文地址:https://www.cnblogs.com/zuidap/p/5776911.html
Copyright © 2011-2022 走看看