这个问题在SO上被问了几次,但解决方案似乎总是将:
添加到action
字符串的末尾,或添加发送方参数,如UIButton
或AnyObject
,但这不适用于我。
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
方法中嵌套函数。