How to call gesture tap on UIView programmatically in swift

I have a UIView and and I have added tap gesture to it: let tap = UITapGestureRecognizer(target: self, action: Selector(“handleTap:”)) tap.delegate = self myView.addGesture(tap) I am trying to call it programmatically in the testfile. sendActionForEvent I am using this function, but it is not working: myView.sendActionForEvent(UIEvents.touchUpDown) It shows unrecognised selector sent to instance. How can … Read more

Can you attach a UIGestureRecognizer to multiple views?

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTapTap:)]; [self.view1 addGestureRecognizer:tapGesture]; [self.view2 addGestureRecognizer:tapGesture]; [tapGesture release]; In the above code only taps on view2 are recognized. If I comment out the third line then taps on view1 are recognized. If I’m right and you can only use a gesture recognizer once, I’m not sure if this is a … Read more

How to disable back swipe gesture in UINavigationController on iOS 7

In iOS 7 Apple added a new default navigation behavior. You can swipe from the left edge of the screen to go back on the navigation stack. But in my app, this behavior conflicts with my custom left menu. So, is it possible to disable this new gesture in UINavigationController? 18 Answers 18

UILongPressGestureRecognizer gets called twice when pressing down

I am detecting if the user has pressed down for 2 seconds: UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; longPress.minimumPressDuration = 2.0; [self addGestureRecognizer:longPress]; [longPress release]; This is how I handle the long press: -(void)handleLongPress:(UILongPressGestureRecognizer*)recognizer{ NSLog(@”double oo”); } The text “double oo” gets printed twice when I press down for longer than 2 seconds. Why … Read more