Swift UIAlertController示例试用,显示错误,但不确定如何修复
} 我在stackoverflow中找到了这段代码,并在Xcode 7上进行了尝试。但它在presentviewcontroller上显示错误,错误为“无法调用非函数类型'UIViewController'的值”。我打错什么了吗Swift UIAlertController示例试用,显示错误,但不确定如何修复,swift,xcode7,Swift,Xcode7,} 我在stackoverflow中找到了这段代码,并在Xcode 7上进行了尝试。但它在presentviewcontroller上显示错误,错误为“无法调用非函数类型'UIViewController'的值”。我打错什么了吗 谢谢错误说明了什么?我将您的代码放在单个视图控制器的viewDidload方法中,该方法工作正常。 class alert { func msg(message: String, title: String = "") { let alertView = UIA
谢谢错误说明了什么?我将您的代码放在单个视图控制器的
viewDidload
方法中,该方法工作正常。
class alert {
func msg(message: String, title: String = "")
{
let alertView = UIAlertController(title: title, message: message, preferredStyle: .Alert)
alertView.addAction(UIAlertAction(title: "Done", style: .Default, handler: nil))
UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(alertView, animated: true, completion: nil)
}