我怎样才能检测到UIImageView的触摸事件 [英] how can i detect the touch event of an UIImageView

查看:101
本文介绍了我怎样才能检测到UIImageView的触摸事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在导航栏上放置了一个图像(UIImageView)。现在我想检测触摸事件并想要处理事件。你能让我知道我该怎么办?

I have placed an image (UIImageView) on the navigation bar. Now I want to detect the touch event and want to handle the event. Could you let me know how can I do that?

谢谢。

推荐答案

实际上,不要这样做。

而是在UIImageView上添加一个带有自定义样式的按钮(除非你指定图像,没有按钮图形)。然后将你想要调用的任何方法附加到那个。

Instead add a button with Custom style (no button graphics unless you specify images) over the UIImageView. Then attach whatever methods you want called to that.

你可以在很多情况下使用这种技术,你真的希望屏幕的某个区域充当按钮而不是弄乱触摸的东西。

You can use that technique for many cases where you really want some area of the screen to act as a button instead of messing with the Touch stuff.

这篇关于我怎样才能检测到UIImageView的触摸事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆