tvOS App UIAlertController UIAlertAction handlers are not called immediately after selecting an action button

549 Views Asked by At

In my tvOS App, I display a UIAlertController with UIAlertAction handlers. The handlers are not called until after a long (10+ second) delay. I've wrapped the UIAlertController in a gcd block to ensure that it's called on the main thread. If I present the UIAlertController with animation set to true then the UIAlertController is not dismissed after selecting an action button. If I present the UIAlertController with animation set to false then the UIAlertController is dismissed after selecting an action button, but the UIAlertAction handler is not called until after a long delay (10sec) and the ui is unresponsive.

dispatch_async(dispatch_get_main_queue(), { () -> Void in
            let alertController = UIAlertController(title: title, message: message, preferredStyle: .Alert)
            let cancelAction = UIAlertAction(title: PWAlertButtonType.No.rawValue, style: .Cancel, handler: { action in
                self.didSelectUnsavedChangesNoButtonType()
            })
            alertController.addAction(cancelAction)

            let OKAction = UIAlertAction(title: PWAlertButtonType.Yes.rawValue, style: .Default, handler: { action in
                self.didSelectUnsavedChangesYesButtonType()
            })
            alertController.addAction(OKAction)
            self.presentViewController(alertController, animated: false, completion:nil)
        })
0

There are 0 best solutions below