2016-05-07 36 views
1

所以我認爲通過打開該應用的應用商店頁面「UIApllication.sharedApplication()的OpenURL」按鈕App store的取消按鈕不起作用

什麼奇怪的是,而不是用一個常規的Web彈出瀏覽器會打開應用商店頁面。

問題是在打開的頁面上有一個取消按鈕。那個按鈕似乎不起作用。任何想法我可能會實現該按鈕?

下面是代碼:(VC()剛剛返回視圖控制器的功能)

static func rate() 
    { 
     crashLog("Opening up itunes page") 
     //https://itunes.apple.com/us/app/toothache-be-the-monster/id1033405285?mt=8 
     if let v = vc() 
     { 
      let url = NSURL(string: "itms://itunes.apple.com/de/app/toothache-be-the-monster/id1033405285?mt=8&uo=4") 
      if UIApplication.sharedApplication().canOpenURL(url!) == true { 
       UIApplication.sharedApplication().openURL(url!) 
      } 
     } 
     neverRateAgain() 
    } 
+0

取消按鈕應該做什麼? – dasdom

+0

我們可以看到您打開應用商店的代碼 – 123FLO321

+0

@ 123FLO321我已添加代碼。 –

回答

1

編輯:現在你添加更多的代碼,讓我告訴你我是如何實現你想實現。

CODE:

func showRateMe() { 
    let alert = UIAlertController(title: "Would you like to rate the App?", message: "We hope you enjoy the App !", preferredStyle: UIAlertControllerStyle.Alert) 
    alert.addAction(UIAlertAction(title: "Rate App now !", style: UIAlertActionStyle.Default, handler: { alertAction in 
     UIApplication.sharedApplication().openURL(NSURL(string : "https://itunes.apple.com/us/app/name/id")!) 
     alert.dismissViewControllerAnimated(true, completion: nil) 
    })) 
    alert.addAction(UIAlertAction(title: "Later!", style: UIAlertActionStyle.Default, handler: { alertAction in 
     alert.dismissViewControllerAnimated(true, completion: nil) 
    })) 
    self.presentViewController(alert, animated: true, completion: nil) 
    alert.addAction(UIAlertAction(title: "NO !", style: UIAlertActionStyle.Default, handler: { alertAction in 
     NSUserDefaults.standardUserDefaults().setBool(true, forKey: "neverRate") 
     alert.dismissViewControllerAnimated(true, completion: nil) 
    })) 
} 

SOLUTION(我認爲):

我在我的代碼中使用:"https://itunes.apple.com/us/app/name/id"

你在你的使用:"itms://itunes.apple.com/de/app/toothache-be-the-monster/id1033405285?mt=8&uo=4"

此致應該:"https://itunes.apple.com/de/app/toothache-be-the-monster/id1033405285?mt=8&uo=4"


施加到這個問題以前版本的舊答案:

如果我沒有記錯的話,這是你需要做什麼:

1)創建取消按鈕與IBAction。

2)IBAction爲做到這一點:

self.dismissViewController() 

3)完成。

這就是我如何「執行取消按鈕」,你在你的問題中寫道。

+0

我正在做一個spritekit應用程序。我不知道在哪裏放置一個ibaction –

+1

@J。Doe向我們展示更多代碼。 – Coder1000

+0

我已編輯並添加示例代碼 –

2

我測試了你的代碼。

問題是,您正在使用itms這將打開iTunes Store。

的simpy使用ITMS-應用代替ITMS所以它會在App Store被打開而不是iTunes Store中。 (不要忘記在你的.plist中改變它)

let url = NSURL(string: "itms-apps://itunes.apple.com/de/app/toothache-be-the-monster/id1033405285?mt=8&uo=4")