我在alert.addAction()上收到錯誤消息。似乎我的項目不知道在哪裏可以找到它,對嗎?使用alert.addAction的未解析標識符
我做了一個沒有按鈕的警報,現在我試圖向它添加按鈕。
所以這是我的警告窗口和代碼中添加的按鈕:
func naamInModelChangedHandler (notification:NSNotification) {
println("De naam in de model is veranderd naar \(model.naam!)")
NSNotificationCenter.defaultCenter().removeObserver(
self,
name: "NAAM_CHANGED",
object: model)
let alert = UIAlertController(title: "Ola", message: "De naam is gewijzigd", preferredStyle: UIAlertControllerStyle.Alert)
self.presentViewController(alert, animated: true, completion: nil)
alert.addAction(okAction)
alert.addAction(cancelAction)
}
我做了一個名爲AlertController一些代碼,使按鈕的UIAlertAction。
let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) { (action) -> Void in
println("Ok geklikt")
}
let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel) { (action) -> Void in
println("Cancel geklikt")
}
但似乎它不知道在哪裏尋找我認爲。我在這裏做錯了什麼?
什麼錯誤? – fluidsonic
你在哪裏宣佈你的行爲和你的戒備?向我們展示更多請 –
您是否在alert.addAction(okAction)之前定義了okAction和cancelAction alert.addAction(cancelAction)? – Amit89