【发布时间】:2017-09-02 23:25:39
【问题描述】:
应用程序试图以模态方式呈现一个活动控制器
我正在尝试创建自定义 UIAlertController。 因此,来自不同地方的工作将更容易。 但我收到了这个错误:
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“应用程序试图以模态方式呈现活动控制器
class CustomAlert: UIAlertController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
private static var sheet : UIAlertController = UIAlertController()
static let instance = CustomAlert()
func create(title: String, message: String) -> CustomAlert {
CustomAlert.sheet = UIAlertController(title: title, message: message, preferredStyle: .actionSheet)
return self
}
func addlibrary() -> CustomAlert{
let libraryAction = UIAlertAction(title: "library", style: .default, handler: nil)
CustomAlert.sheet.addAction(libraryAction)
return self
}
func show(on vc : UIViewController){
UIApplication.shared.keyWindow?.rootViewController?.present(vc, animated: true, completion: nil)
}
}
问题出在哪里? 谢谢
【问题讨论】:
标签: swift swift3 uialertcontroller