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
  • 相关阅读:
    Linq聚合操作之Aggregate,Count,Sum,Distinct源码分析
    Linq分区操作之Skip,SkipWhile,Take,TakeWhile源码分析
    Linq生成操作之DefautIfEmpty,Empty,Range,Repeat源码分析
    Linq基础操作之Select,Where,OrderBy,ThenBy源码分析
    PAT 1152 Google Recruitment
    PAT 1092 To Buy or Not to Buy
    PAT 1081 Rational Sum
    PAT 1084 Broken Keyboard
    PAT 1077 Kuchiguse
    PAT 1073 Scientific Notation
  • 原文地址:https://www.cnblogs.com/zuidap/p/5776911.html
Copyright © 2011-2022 走看看