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
  • 相关阅读:
    [转]基于S2SH框架的项目—antlr-2.7.2.jar包冲突问题
    输入法那没有小键盘的图标解决方法
    Chrome百度不显示中文字体
    转:数据库范式(1NF 2NF 3NF BCNF)
    转:海明纠错码
    奇阶魔方阵
    字符串的模式匹配
    红黑树
    排序算法总结
    关于面试总结9-接口测试面试题
  • 原文地址:https://www.cnblogs.com/zuidap/p/5776911.html
Copyright © 2011-2022 走看看