In the project I'm working on, I had to write a UIAlert helper module that will display pop-ups here and there in my iOS application. Pop-ups are written as class functions, which I can just call anywhere in the code (the class is static and therefore all functions).
Now I encounter a very strange error if if you release the warning once and then open it again, its actions will no longer work (as in the case, the action handler is not called). It works if you click the action the first time a popup appears, though ...
Here is the code for a specific popup for which this error (no other popups are affected at all):
static func popSkipWalkthrough() { let alert = UIAlertController(title: "Skip", message: "whatever", preferredStyle: .Alert) alert.addAction(cancelAction) alert.addAction(skipWalkthroughAction) appDelegate.window!.rootViewController!.presentViewController(alert, animated: true, completion: nil) }
skipWalkthroughAction defined as follows:
static let skipWalkthroughAction = UIAlertAction(title: "Continue", style: .Default, handler: { (action: UIAlertAction!) -> Void in appDelegate.setWindowViewTo("NavCtrl", navigateTo: false) CallIn.Settings.didWalkthrough = true })
And cancelAction is defined as:
static let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)
This popup, in particular, is displayed every time you click the skip button in the last step of the passage ...
I have tried some tips on what is the reason for this behavior, and I think this could have something to do with the popup that is not really getting released, but I'm not at all sure about it ...
Any ideas?