gpt4 book ai didi

swift - UIAlertAction 错误

转载 作者:行者123 更新时间:2023-11-30 10:13:39 26 4
gpt4 key购买 nike

我正在尝试向 UIAlertController 添加一些操作,但是当我向其传递闭包时出现错误。我想将该闭包作为操作的处理程序传递,但我收到一条错误消息。 enter image description here

 override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath){

let optionMenu = UIAlertController(title: nil, message: "What do you want to do?", preferredStyle: .ActionSheet)
let cancel = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)
optionMenu.addAction(cancel)

self.presentViewController(optionMenu, animated: true, completion: nil)



let callActionHandler = { (action:UIAlertAction) -> Void in

let alertMessage = UIAlertController(title: "No service", message: "Sorry the phone option is not working right now, try again later", preferredStyle: .Alert)

alertMessage.addAction(UIAlertAction(title: "Ok", style: .Default, handler: nil))

self.presentViewController(alertMessage, animated: true, completion: nil)

}

let callAction = UIAlertAction(title: "Call " + "123-000-\(indexPath.row)", style: UIAlertActionStyle.Default , handler: callActionHandler)



optionMenu.addAction(callAction)


}

最佳答案

已解决。您只错过了!。更改以下行

let callActionHandler = { (action:UIAlertAction) -> 无效

let callActionHandler = { (action:UIAlertAction!) -> 无效

就是这样!

关于swift - UIAlertAction 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31468318/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com