码迷,mamicode.com
首页 > 其他好文 > 详细

UIScrollView无法响应touch事件的解决方法

时间:2014-11-21 12:09:24      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   sp   on   div   

用过UIScrollView的都会发现UIScrollView不会响应touch事件,这样就无法在touches相关的方法中做一些事情了,比如收回键盘等等。其实写个categroy就可以解决这个问题了。

具体实现如下:

@implementation UIScrollView (UITouchEvent)

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [[self nextResponder] touchesBegan:touches withEvent:event];
    [super touchesBegan:touches withEvent:event];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    [[self nextResponder] touchesMoved:touches withEvent:event];
    [super touchesMoved:touches withEvent:event];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    [[self nextResponder] touchesEnded:touches withEvent:event];
    [super touchesEnded:touches withEvent:event];
}

@end

备注:转自http://blog.csdn.net/volcan1987/article/details/6677370

UIScrollView无法响应touch事件的解决方法

标签:style   blog   http   io   ar   color   sp   on   div   

原文地址:http://www.cnblogs.com/haili/p/4112369.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!