如果删除照片的功能返回错误,我想向用户显示该错误.
Xcode在errorController.addAction行上失败,消息“无法调用非函数类型UIAlertAction的值”
我正在使用Swift 2
@IBAction func deletePhoto(sender: AnyObject) { let alertController = UIAlertController(Title: "Delete Photo",message: "Are you sure you want to delete this photo?",preferredStyle: .Alert) let okAction = UIAlertAction(Title: "OK",style: .Default) { UIAlertAction in self.photoGateway!.delete(self.photo!.ID!,completion: { (withError: Bool) -> VoID in if (withError == true) { let errorController = UIAlertController(Title: "Delete Failed",message: "blah",preferredStyle: UIAlertControllerStyle.Alert) // The next line is causing the error errorController.addAction(UIAlertAction(Title: "Ok",style: UIAlertActionStyle.Default,handler: nil)) self.presentVIEwController(errorController,animated: true,completion: nil) } else { self.dismissVIEwControllerAnimated(true,completion: nil) } }) } let cancelAction = UIAlertAction(Title: "Cancel",style: .Cancel) { UIAlertAction in print("Cancelled") } alertController.addAction(okAction) alertController.addAction(cancelAction) self.presentVIEwController(alertController,completion: nil)}
如果我拿出违规行,那么一切正常,只是用户无法解除警报
解决方法 固定它.更改:errorController.addAction(UIAlertAction(Title: "Ok",handler: nil))
至:
errorController.addAction(UIKit.UIAlertAction(Title: "Ok",handler: nil))总结
以上是内存溢出为你收集整理的swift – 无法调用非函数类型UIAlertAction的值全部内容,希望文章能够帮你解决swift – 无法调用非函数类型UIAlertAction的值所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)