我想通过UIScrollView
更改UIPanGestureRecognizer
'中心。滚动视图垂直滚动。我横向平移它。问题是当scrollview还在滚动时如何检测UIPanGestureRecognizer
???
提前谢谢!
答案 0 :(得分:0)
修改:您可以自定义UIScrollView
并覆盖此方法:
#import "MyScrollView.h"
@implementation MyScrollView
- (BOOL)touchesShouldCancelInContentView:(UIView *)view
{
return YES;
}
@end
self.panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
self.panGesture.delegate = self;
[self.view addGestureRecognizer:self.panGesture];
- (void)handlePan:(UIGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
CGPoint offset = self.scrollView.contentOffset;
offset.y = self.scrollView.contentSize.height/2;
self.scrollView.contentOffset = offset;
}
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return YES;
}