「レートアプリ」アラートを作成したいのですが、何らかの理由でそれを表示する前に割り当てを解除します。UIAlertControllerはプレゼンテーションの前に割り当て解除されます
は、ここでは、コードです:
func showAlert() {
if #available(iOS 8.0, *)
{
let alertController = UIAlertController(title: "Rate App", message: "Rate this app now", preferredStyle: .Alert)
let neverAction = UIAlertAction(title: "Never Show This Again", style: .Destructive, handler: { (action: UIAlertAction) in
self.userDefaults.setBool(true, forKey: "rateAlertRejected")
})
let rateAction = UIAlertAction(title: "Rate Now", style: .Default, handler: { (action: UIAlertAction) in
// Rate App
})
let remindAction = UIAlertAction(title: "Remind Me Later", style: .Cancel, handler: nil)
alertController.addAction(rateAction)
alertController.addAction(neverAction)
alertController.addAction(remindAction)
presentViewController(alertController, animated: true, completion: nil)
}
else
{
// Identical code (using UIAlertView) for iOS 7 which works perfectly
}
}
メソッドが実行(特定の条件ではなく、テスト目的のためにそれが毎回ん)カスタムアンワインドセグエ後。
なぜこの問題がありますか?以前はUIAlertController
を使っていましたが、問題はありませんでした。
ここから 'showAlert'関数を呼び出していますか? – Shubhank
カスタムunwind segueの後に実行するメソッドで。メソッドは他のものも同様に行い、完全に機能します。 – Lawrence413