@IBAction func createAlert(sender: AnyObject) {
if #available(iOS 8.0, *) {
let alert = UIAlertController(title: "Hey there!", message: "Are you sure?", preferredStyle: UIAlertControllerStyle.Alert)
} else {
if let alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: { (action) -> Void in
self.dismissViewControllerAnimated(true, completion: nil)
}))
}
self.presentViewController(alert, animated: true, completion: nil)
}
我不斷收到錯誤消息。 1)'if'條件後的'{' 2)條件中的變量綁定需要一個初始化器。 請幫忙!!!!創建UIAlertController時出錯
更新Xcode。你的不認識'#可用(iOS 8.0,*)'。 – Moritz
'如果讓alert#'在它後面沒有任何阻止。如果甚至需要? –
如果讓alert.addAction(...沒有打開'{' – pkacprzak