c# - 如何覆盖 CustomButton 类中的 TouchUpInside 事件?
<p><p>我有一个自定义按钮:</p>
<pre><code>public class CustomButton : UIButton
{
public void HandleTouchUpInside(object sender, EventArgs ea)
{
Console.Write("test tap");
}
}
</code></pre>
<p>所以我想在这个类中覆盖 TouchUpInside 事件...怎么做?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>它对你有用吗?</p>
<pre><code>public class CustomButton : UIButton
{
public CustomButton()
{
TouchUpInside += HandleTouchUpInside;
// or new EventHandler(HandleTouchUpInside)
// if Xamarin compiler/runtime doesn't allow such shorter code
}
public void HandleTouchUpInside(object sender, EventArgs e)
{
Console.Write("test tap");
}
}
</code></pre></p>
<p style="font-size: 20px;">关于c# - 如何覆盖 CustomButton 类中的 TouchUpInside 事件?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/28687996/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/28687996/
</a>
</p>
页:
[1]