UIButton在编码阶段触及内部事件连接?

时间:2011-03-31 07:22:27

标签: events ios4 uibutton

我在编码阶段创建UIButton并且从不使用Interface Builder所以如何调用touch up inside事件来与编码阶段中的任何方法挂钩?

1 个答案:

答案 0 :(得分:37)

[button addTarget:self action:@selector(BtnPressed:) forControlEvents:UIControlEventTouchUpInside];

斯威夫特3:

button.addTarget(self, action: #selector(ViewControllerName.BtnPressed), for: .touchUpInside)