[英]UIButton Action not working in swift
I have two classes UIVIewController and UITableviewcell. 我有两个类UIVIewController和UITableviewcell。 In UITableviewcell, i have a button and the button action should be in UIViewController. 在UITableviewcell中,我有一个按钮,该按钮动作应在UIViewController中。 How can i pass a class and set delegate in button action. 我如何通过一个类并在按钮操作中设置委托。
i tried this code, 我尝试了这段代码,
//UIVIewController //的UIViewController
cell.createButton(self)
func buttonClick(object:AnyObject){
println("Button Clicked")
}
//UITableViewCell //定义UITableViewCell
func createButton(delegate:AnyObject){
//button created.
button.addTarget(delegate, action: "buttonClick:", forControlEvents: UIControlEvents.TouchUpInside)
}
But the above code is not working. 但是上面的代码不起作用。 'buttonClick' function is not calling 'buttonClick'函数未调用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.