0

Now I have a view with tow buttons in it, I want to swipe the view to do something,But I found when my touches begin or end inside buttonView , it undo the action. how can I resolve it?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
jaderY
  • 3
  • 4
  • There're two tow buttons in the superview.I want to select the button on the left by swiping to the left,and vice versa。However, if the touch begins or ends on the buttons, the touch event will be cancelled. – jaderY Aug 12 '15 at 02:56

1 Answers1

0

First, you have to create a gesture recognizer. For the action, be sure to include the IBAction the left button is firing.

let swipeLeft = UISwipeGestureRecognizer(target: self, action: "leftButtonPressed:")

Next, assign the direction. In this case, you'll be swiping left.

swipeLeft.direction = UISwipeGestureRecognizerDirection.Left

Lastly, add the gesture to the superview.

self.view.addGestureRecognizer(swipeLeft)

Hope this helps! :)

xNightxOwl
  • 538
  • 5
  • 7
  • Thanks for your answer.But i still want the buttons to work independently without the swiping. – jaderY Aug 12 '15 at 03:48