UIAlertController在iPad上触发警告

时间:2017-06-28 00:08:31

标签: ios swift3 uialertcontroller

我有一个问题是在我的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已经被解雇之后执行动作处理程序。在我的视图中覆盖解雇功能根本不会被触发。

我是否必须忽略该警告,或者我可以添加任何内容来阻止动画?

0 个答案:

没有答案