I have implemented the code below but i have a warning message:
Warning: Attempt to present on whose view is not in the window hierarchy! on paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue)
and the alert is not displayed. [edit]If I rotate the phone, the alert is displayed just after the rotation [/edit]
Here is my code:
func paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue) {
alert("Félicitations", message: "Vous avez restauré vos packs, cliquez sur ok pour les télécharger !")
}
func alert(title:String, message:String = "") {
let alert = UIAlertController(title: title, message:message, preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default) { _ in
if title == "Félicitations" {
let next = self.storyboard?.instantiateViewControllerWithIdentifier("TelechargementVC") as! TelechargementViewController
self.presentViewController(next, animated: true, completion: nil)
}
})
self.presentViewController(alert, animated: true){}
}
NB : The alert function is called from other functions without problem.
How can I solve this?