如何让UIScrollView里面的UIImageView响应touch事件
2011-09-20 14:45
459 查看
UISCrollView本身不支持touch, 需要重写UIImageView类,响应touch事件,委托给你的类处理, 重写UIImageView类代码如下,然后在要添加UIImageView的类中,实现下面代码定义的协议 #import <Foundation/Foundation.h> @protocol ImageViewDelegate @optional -(void)TouchesBegin:(NSInteger)imageTag; @end @interface CustomizeImageView : UIImageView { //声明一个代理 id<ImageViewDelegate> delegate; } @property (nonatomic,assign) id<ImageViewDelegate> delegate; @end #import "CustomizeImageView.h" @implementation CustomizeImageView @synthesize delegate; - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { //NSLog(@"delegate:%@",self.delegate); [self.delegate TouchesBegin:self.tag]; } - (void)dealloc { [super dealloc]; } @end UIScrollView把touch事件隔离了,它默认响应的是drag事件。 重写UIImageView类,然后往UIScrollView添加CustomizeImageView,并且把self. delegate = self; 这样,UIImageView就把touch事件委托给别人处理了, 在要处理的类中,实现上述协议即可 |
相关文章推荐
- 解决UIScrollView,UIImageView等控件不能响应touch事件的问题
- 解决UIScrollView,UIImageView等控件不能响应touch事件的问题
- 关于UIScrollview不能响应touch事件的解决办法
- UIScrollView无法响应touch事件的解决办法
- UIScrollView UICollectionView 无法响应touch事件
- iphone 如何设置在uiImageView上添加按钮,按钮透明并且能响应事件
- 如何屏蔽父view的touch事件到,并且响应self的touch
- 『IOS』UIScrollView无法响应touch事件的解决办法
- UIScrollView不能响应touch事件的解决办法
- ios 中UIScrollView如何同时响应scrollViewDidScroll 与 touchesMoved等事件
- UIScrollView无法响应touch事件的解决办法
- UIScrollView无法响应touch事件的解决办法
- UIScrollView无法响应touch事件解决方法
- UIScrollView不能响应touch事件的解决办法
- IOS开发:UIScrollView类介绍及如何简单地截获touch事件
- 解决小米系统下ViewPager、ScrollView内嵌套WebView时,Touch事件不响应的问题
- iphone--UIImageView响应点击事件
- 让一个UIImageView响应点击事件
- UIImageView响应点击事件
- 解决UIScrollView截获touch事件的一个极其简单有效的办法