无法识别的选择器发送到实例- Swift



这个问题在SO上被问了几次,但解决方案似乎总是将:添加到action字符串的末尾,或添加发送方参数,如UIButtonAnyObject,但这不适用于我。

下面是我的代码:(在cellForRowAtIndexPath函数内)
    let mapsbut = cell.viewWithTag(912) as! UIButton
    mapsbut.addTarget(self, action: "mapsHit:", forControlEvents: UIControlEvents.TouchUpInside)
    func mapsHit(sender: UIButton!){
        passBuild = buildings[indexPath.row]
        performSegueWithIdentifier("mapSegue2", sender: self)
    }
    return cell

你知道出了什么问题吗?

尝试将mapsHit函数移出cellForRowAtIndexPath:函数,使其成为全局(在视图控制器上下文中),而不是在cellForRowAtIndexPath方法中嵌套函数。

最新更新