如何检测UIImageView的触摸事件? [英] How can I detect the touch event of an UIImageView?

查看:69
本文介绍了如何检测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. 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.

在很多情况下,您确实希望将屏幕的某些区域用作按钮而不是弄乱Touch东西时,可以使用该技术.

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天全站免登陆