使用 alert.addAction 未解析的标识符
Use of unresolved identifier using an alert.addAction
我在 alert.addAction() 上遇到错误。好像我的项目不知道在哪里可以找到它,对吗?
我制作了一个没有按钮的警报,现在我正在尝试向其中添加按钮。
这是我的警报 window 和添加按钮的代码:
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")
}
但我想它似乎不知道去哪里找。我在这里做错了什么?
这样做
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)
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")
}
alert.addAction(okAction)
alert.addAction(cancelAction)
}
我在 alert.addAction() 上遇到错误。好像我的项目不知道在哪里可以找到它,对吗?
我制作了一个没有按钮的警报,现在我正在尝试向其中添加按钮。
这是我的警报 window 和添加按钮的代码:
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")
}
但我想它似乎不知道去哪里找。我在这里做错了什么?
这样做
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)
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")
}
alert.addAction(okAction)
alert.addAction(cancelAction)
}