Detect drag with finger down
I've got a Scroll View with Paging View controller. The interface looks like this:
@interface ScrollViewWithPagingViewController : UIViewController <UIScrollViewDelegate> {
UIScrollView *scrollView;
UIPageControl *pageControl;
NSMutableArray *viewControllers;
}
and it lets me switch pages as expected when you do a swipe.
However, I'd like it to switch pages if you 开发者_运维知识库have one finger down and then do a swipe with a second finger which it currently doesn't do. Not quite sure how to proceed though.
Add a UIGestureRecogniser?
Subclass UIScrollView?
I would probably set a UIGestureRecognizer
on the UIScrollView
, specifically a UISwipeGestureRecognizer
. Then you would want to set the numberOfTouchesRequired
property:
swipeGesture.numberOfTouchesRequired = 2;
With any luck, this gesture will fire and allow you to cancel any other events (so that you don't scroll, or zoom, or...something else).
Just as a hint, if I got you correctly what you are trying to do is a pinch right? Like when you zoom out on iphone. If you keep a finger down and swipe the others in some direction is IMHO a pinch. If that is the gesture you are trying to use you should look into UIGestureRecogniser
and in particular into UIPinchGestureRecognizer
(check http://bit.ly/f5sZMw) (developer.apple.com link).
-- Umberto
精彩评论