通过NSTouches区分UISwipe手势

时间:2014-02-04 12:01:28

标签: ios drawrect uiswipegesturerecognizer touches

我有一个用户可以在iPad上用手指画画的视图 他可以使用1-4个手指来绘制任何东西 我在NSTouches的帮助下画画 现在,客户希望我添加一个滑动手势来显示隐藏的菜单 这件事是否可以实现,如果是,那么如何?

1 个答案:

答案 0 :(得分:0)

 UISwipeGestureRecognizer *rightRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];  // MENTION WHAT YOU WANT TO DO IN rightSwipeHandle METHOD WHEN SWIPED RIGHT
rightRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[rightRecognizer setNumberOfTouchesRequired:1];  // YOU CAN INCREASE THE NUMBER OF TOUCHES 
//add the your gestureRecognizer , where to detect the touch..
[listView1 addGestureRecognizer:rightRecognizer];
[rightRecognizer release];

UISwipeGestureRecognizer *leftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipeHandle:)];  // MENTION WHAT YOU WANT TO DO IN leftSwipeHandle METHOD WHEN SWIPED RIGHT
leftRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[leftRecognizer setNumberOfTouchesRequired:1];
[listView1 addGestureRecognizer:leftRecognizer];
[leftRecognizer release];


UISwipeGestureRecognizer *upRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(upSwipeHandle:)];  // MENTION WHAT YOU WANT TO DO IN upSwipeHandle METHOD WHEN SWIPED RIGHT
upRecognizer.direction = UISwipeGestureRecognizerDirectionUp;
[upRecognizer setNumberOfTouchesRequired:1];
[listView1 addGestureRecognizer:upRecognizer];
[upRecognizer release];


UISwipeGestureRecognizer *downRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(downSwipeHandle:)];  // MENTION WHAT YOU WANT TO DO IN downSwipeHandle METHOD WHEN SWIPED RIGHT
downRecognizer.direction = UISwipeGestureRecognizerDirectionDown;
[downRecognizer setNumberOfTouchesRequired:1];
[listView1 addGestureRecognizer:downRecognizer];
[downRecognizer release];