iPad - UIImageView 响应触摸
在 MonoTouch 中,如何获取 UIImage 或 UIImageView 在单击时触发委托或其他内容?
In MonoTouch how do I get a UIImage or UIImageView to fire off a delegate or something when clicked?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 Dimitris 指出的那样,您需要继承 UIImageView 的子类,并确保 userInteractionEnabled 标志设置为 true。
我应该指出,在大多数情况下,人们打算让 UIImageView 响应交互,这些问题可以通过创建带有图像的 UIButton 实例轻松解决。
Exactly as Dimitris pointed out, you'll want to subclass UIImageView, and also ensure that the userInteractionEnabled flag is set to true.
I should point out that in most cases where people intend to have a UIImageView respond to interaction, these problems can just as easily be fixed by creating a UIButton instance with an image instead.
您必须根据您想要执行的操作对其进行子类化(UIImageView)并重写 TouchesBegan、TouchesMoved 或 TouchesEnded 方法之一。
You have to subclass it (the UIImageView) and override one of TouchesBegan, TouchesMoved or TouchesEnded methods, according to what you want to do.