[英]How do I programmatically make clicking on a UIImageView do something on the iPhone?
I have programmatically added a UIImageView. 我已经以编程方式添加了UIImageView。 How do I make it send a message to my controller when the users clicks it, sending itself as the only parameter?
当用户点击它时,如何让它向我的控制器发送消息,将自己作为唯一参数发送?
I wouldn't use a UIImageView unless there was some other compelling reason. 除非有其他令人信服的理由,否则我不会使用UIImageView。 I'd just use a custom UIButton and use the UIImage as its background.
我只使用自定义UIButton并使用UIImage作为其背景。
I'd just put a custom button over the UIImage view, and use normally - buttons with Custom style are invisible and so will not obscure the image. 我只是在UIImage视图上放置一个自定义按钮,并且正常使用 - 具有自定义样式的按钮是不可见的,因此不会遮挡图像。 It's also a great way to turn regions of text into clickable areas as well.
这也是将文本区域转换为可点击区域的好方法。
Or, you could assign the custom image as a graphic background for the button. 或者,您可以将自定义图像指定为按钮的图形背景。
just put a button over the imageview, with the Alpha attribute set to 0.10 or less. 只需在imageview上放一个按钮,Alpha属性设置为0.10或更小。 you can capture the button's tap event but almost cannot see it.
你可以捕捉按钮的点击事件,但几乎看不到它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.