UIScrollView解决无法触发手势

//创建一个分类

//.h

#import <UIKit/UIKit.h>

@interface UIScrollView (Touch)

 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;

@end

 

//.m

#import "UIScrollView+Touch.h"

 @implementation UIScrollView (Touch)

 

- (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

 

/**工程中调用*/

- (void)viewDidLoad {

    [super viewDidLoad]; 

    //实现scroll触摸屏幕

    [self touchesBegan:nil withEvent:nil];

    [self touchesMoved:nil withEvent:nil];

    [self touchesEnded:nil withEvent:nil];

}

 

posted @ 2015-11-25 11:47  TheYouth  阅读(423)  评论(0编辑  收藏  举报