ios - 如何将观察者添加到 UIButton?
<p><p>我希望在用户触摸按钮 (UIControlEventTouchUpInside) 时收到信号。如何将观察者添加到 UIButton?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>查看 <a href="http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIControl_Class/Reference/Reference.html" rel="noreferrer noopener nofollow">UIControl</a> 的文档.</p>
<pre><code>[myButton addTarget:self
action:@selector(touch:)
forControlEvents:UIControlEventTouchUpInside];
</code></pre>
<p>此方法适用于从 <code>UIControl</code> 继承的任何东西(包括但不限于 <code>UIButtons</code> :)</p></p>
<p style="font-size: 20px;">关于ios - 如何将观察者添加到 UIButton?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/8520515/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/8520515/
</a>
</p>
页:
[1]