UIAlertController会自动消失

Dar*_*lia 7 ios swift uialertcontroller

所以我有一个使用以下代码创建的UIAlertController:

let alertView = UIAlertController(title: "Warning", message: "You have made  changes to \(workoutTemplate!.name). Do you wish to overwrite these changes?", preferredStyle: UIAlertControllerStyle.ActionSheet)

            alertView.addAction(UIAlertAction(title: "Yes, Overwrite", style: UIAlertActionStyle.Destructive, handler: {(alert: UIAlertAction!) in

                //... some code

            }))

            alertView.addAction(UIAlertAction(title: "No, Rename", style: UIAlertActionStyle.Default, handler: {(alert: UIAlertAction!) in

                   //..some more code                     
            }))

self.presentViewController(alertView, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

我已将警报控制器设置为按下按钮显示,但警报会自动消失:

在此输入图像描述

编辑:发现问题!这对我来说是一个愚蠢的疏忽.上面的代码在交换机中.转换后,我立刻打了个self.dismissViewController()电话.我遗漏了一个else声明,VC在呈现AlertController后试图解雇自己.但是,由于AlertController在此调用时位于导航堆栈的顶部,因此它被解除了.