首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIAlertAction错误

UIAlertAction错误
EN

Stack Overflow用户
提问于 2015-07-17 04:17:54
回答 1查看 475关注 0票数 0

我试图向一个UIAlertController添加一些操作,但是当我传递一个闭包时,我会得到一个错误。我想将这个闭包作为一个操作的处理程序传递,但是我得到了一个错误消息。

代码语言:javascript
复制
 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)


    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-17 04:38:44

解决了。只有你错过的!。更改下面一行

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

使用

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

就这样!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31468318

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档