我有一个问题是在我的UIView中添加UIAlertController并防止应用程序在iPad上崩溃,我将它附加到UIBarButtonItem . 现在,每当第一次警报被解雇时,我都会收到警告:

[警告] <_UIPopoverBackgroundVisualEffectView 0x7fbfee560c20>被要求为其不透明度设置动画 . 这将导致效果出现断裂,直到不透明度返回到1 .

我知道这个问题之前曾被问过几次,但没有一个答案似乎解决了当前版本的iOS中的问题 .

我试图关闭动画,因为这似乎有所帮助,但如果任何按钮是选项卡,我无法禁用动画 . 如何防止UIAlertController的动画被解除?

我的代码:

let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
    if let popoverPresentationController = optionMenu.popoverPresentationController {
        popoverPresentationController.barButtonItem = button
    }

    let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: "Cancel"), style: .cancel, handler: nil)
    optionMenu.addAction(cancelAction)

    let editAction = UIAlertAction(title: NSLocalizedString("Edit", comment: "Edit"), style: .default, handler: {
        (action:UIAlertAction!) -> Void in
        self.performSegue(withIdentifier: "editBirthday", sender: self)
    })
    optionMenu.addAction(editAction)

    let deleteAction = UIAlertAction(title: NSLocalizedString("Delete", comment: "Delete"), style: .destructive, handler: {
        (action:UIAlertAction!) -> Void in
        if let appDelegate = (UIApplication.shared.delegate as? AppDelegate) {
            let context = appDelegate.persistentContainer.viewContext
            context.delete(self.birthday)
            appDelegate.saveContext()
        }
        self.navigationController?.popToRootViewController(animated: true)
    })
    optionMenu.addAction(deleteAction)

    present(optionMenu, animated: true, completion: nil)

我可以在没有任何警告的情况下调用optionMenu.dismiss(animated:false,completion:nil) . 但是,在optionMenu已经被解雇之后执行动作处理程序 . 在我的视图中覆盖dismiss函数根本不会被触发 .

我是否必须忽略警告或者我可以添加什么来阻止动画?