Actually, I want to implement left and right scroll in UIScrollview. I have a scrollview with content size (768,1500). I tried this, but the problem is that sometimes it does not detect swipe and scrolls there. so now I want to disable 2-finger scrolling.
swipeGesture = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(nextswipedScreen:)] autorelease]; swipeGesture.numberOfTouchesRequired=2; swipeGesture.direction = UISwipeGestureRecognizerDirectionLeft; [self addGestureRecognizer:swipeGesture]; swipeGesture = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(previousswipedScreen:)] autorelease]; swipeGesture.numberOfTouchesRequired=2; swipeGesture.direction = UISwipeGestureRecognizerDirectionRight; [self addGestureRecognizer:swipeGesture];
I tried a custom scrollview for this, but I have a problem with the touchhesBegan method. not calling him every time. even I tried this but couldn't stop two-finger scrolling in UIScrollview.
for (UIGestureRecognizer *mgestureRecognizer in _scrollView.gestureRecognizers) { if ([mgestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) { UIPanGestureRecognizer *mpanGR = (UIPanGestureRecognizer *) mgestureRecognizer; mpanGR.minimumNumberOfTouches = 1; mpanGR.maximumNumberOfTouches = 1; } }
Let me know if you have any solution or alternative for this.
iphone uiscrollview uigesturerecognizer
Paras gandhi
source share