我在编码阶段创建UIButton
并且从不使用Interface Builder所以如何调用touch up inside
事件来与编码阶段中的任何方法挂钩?
答案 0 :(得分:37)
[button addTarget:self action:@selector(BtnPressed:) forControlEvents:UIControlEventTouchUpInside];
斯威夫特3:
button.addTarget(self, action: #selector(ViewControllerName.BtnPressed), for: .touchUpInside)