在我的tvOS应用程序中,我显示了一个带有UIAlertAction处理程序的UIAlertController . 直到长时间(10秒)延迟后才会调用处理程序 . 我已经将UIAlertController包装在一个gcd块中,以确保它在主线程上被调用 . 如果我将UIAlertController的动画设置为true,那么在选择动作按钮后UIAlertController不会被解除 . 如果我将UIAlertController的动画设置为false,则在选择动作按钮后,UIAlertController将被解除,但是在长时间延迟(10秒)之后UIAlertAction处理程序才会被调用,并且ui没有响应 .

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)
        })