how can i detect the touch event of an UIImageView
来源:互联网 发布:颈椎病运动疗法知乎 编辑:程序博客网 时间:2024/05/22 00:53
A UIImageView
is derived from a UIView
which is derived from UIResponder
so it's ready to handle touch events. You'll want to provide the touchesBegan
, touchesMoved
, andtouchesEnded
methods and they'll get called if the user taps the image. If all you want is a tap event, it's easier to just use a custom button with the image set as the button image. But if you want finer-grain control over taps, moves, etc. this is the way to go.
You'll also want to look at a few more things:
Override
canBecomeFirstResponder
and return YES to indicate that the view can become the focus of touch events (the default is NO).Set the
userInteractionEnabled
property to YES. The default forUIViews
is YES, but forUIImageViews
is NO so you have to explicitly turn it on.If you want to respond to multi-touch events (i.e. pinch, zoom, etc) you'll want to set
multipleTouchEnabled
to YES.
- how can i detect the touch event of an UIImageView
- how can i detect the touch event of an UIImageView
- How can I detect the Android runtime (Dalvik or ART)?
- How can I get the IPv4 address of an interface in linux from C code ?
- How can I set the background of UITableView (the tableview style is "Grouped") to use an image?
- How can I flip a UIImageView?
- How can i style an Android Switch?
- How can I style an Android Switch?
- How can I combine elements of an array that have a common element?
- How can I throw an exception without losing the original stack trace information in .NET?
- How can i get hold of all of the visible items in my QListView?
- How one VBA project can use an object declared in the class module of another project
- how hard can it be? Estimating the difficulty of visual search in an image
- 《How hard can it be? Estimating the difficulty of visual search in an image》和 PPT
- How can i change the title?
- How can I overload the prefix and postfix forms of operators ++ and --
- How can I determine the byte offset of a field within a structure?
- How can I insert a checkbox into the header of my view?
- js+flash 剪切板复制粘贴 兼容ie chrome firefox flash10
- 算法入门--插入排序
- How to use custom delegates in Objective-C
- 汉字总共有多少个
- Console命令详解,让调试js代码变得更简单
- how can i detect the touch event of an UIImageView
- Metro风格界面
- oracle 级联更新
- 病毒的手工排除与分析(更新完毕)
- 代码点与代码单元
- 14个华丽的javascript图表资源和插件
- ::的意义(小知识)VC里::后跟函数什么意思
- C#如何使用数据库
- 地址译码电路设计实验