Reputation: 1484
Here is my problem (on Xcode 6.0.1, coding in Swift, using iOS 7.1 and 8.0): I am going from one view to another using a Swipe Gesture Recogniser (with the Action Segue "present modally
").
Before this I was using a button "next
" to go from one view to another. I created an @IBAction
for this button next that was performing, let say, a simple println("test")
.
@IBAction func nextPressed(sender: AnyObject) {
println("test")
}
If I run my app, when I press the button Next, I go to the next view and "test
" appears in the consol.
Now I do the same for a Swipe Gesture Recogniser, let say I create an @IBAction
for the Swipe Gesture Recogniser (so I ctrl-click on the gesture icon next to the view controller icon at the top of the view, then drag into the code).
@IBAction func swipeGestureDone(sender: AnyObject) {
println("test")
}
If I run my app, when I swipe on the screen, I go to the next view but the "test" does not appear in the consol. I cannot figure out how to execute a function when I use a Swipe to go from one view to another. It is apparently because there is no "Sent Events" for a Swipe Gesture Recogniser as for a Button. I don't know how to do it. Everything seems to be well connected in the Connection inspector though.
Upvotes: 2
Views: 774
Reputation: 1
I have a similar problem with a UITapGestureRecognizer. Here are a couple of things I found as solutions. They have not worked in my case, but maybe they will fix your issue:
Try selecting the type of object a UISwipeGestureRecognizer instead of AnyObject.
@IBAction func swipeGestureDone(sender: UISwipeGestureRecognizer) {
println("test")
}
Also make sure that your view recognises gestures by adding
yourView.userInteractionEnabled = true
Upvotes: 0
Reputation: 80265
Set cancelsTouchesInView
of the recognizer to true
. It does what it says.
Upvotes: 0