Quantcast
Channel: Can you attach a UIGestureRecognizer to multiple views? - Stack Overflow
Browsing all 14 articles
Browse latest View live
↧

Answer by Naqeeb for Can you attach a UIGestureRecognizer to multiple views?

To add a tap gesture to multiple views in Swift, you can use a loop to iterate through the views and add the gesture recognizer to each one. Here's an example:let views = [view1, view2, view3, view4]...

View Article


Answer by RyanNa for Can you attach a UIGestureRecognizer to multiple views?

I know this is an old post but I figured something similar and hopefully it's useful someone else. I simply stored my imageViews in an array and assigned it to to the same gesture recognizer in a...

View Article


Answer by Martin for Can you attach a UIGestureRecognizer to multiple views?

You could create a generic extension on view to add gesture recognizers easily.This is just an example but it could look like thisextension UIView { func setGestureRecognizer<Gesture:...

View Article

Answer by Raynaldio Limarga for Can you attach a UIGestureRecognizer to...

if you have fixed view I suggest you doing something like this[self.view1 addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTapTap:)]];[self.view2...

View Article

Answer by George Asda for Can you attach a UIGestureRecognizer to multiple...

For Swift 3 in case anyone requires this:Based on Bhavik Rathod Answer above. func setGestureRecognizer() -> UIPanGestureRecognizer { var panRecognizer = UIPanGestureRecognizer() panRecognizer =...

View Article


Answer by rathodbhavikk for Can you attach a UIGestureRecognizer to multiple...

We can do something Like this, it's easy and simple1) create function as below in your controller (this function will return GestureRecognizer)-(UITapGestureRecognizer*)setRecognizer{...

View Article

Answer by febaisi for Can you attach a UIGestureRecognizer to multiple views?

What about re write (recreate) your GestureRecognize every time that you add a gesture recognizer pointing to the same func. In below case it works. I am using IBOutletCollectionSwift 2:@IBOutlet var...

View Article

Answer by AnkitRox for Can you attach a UIGestureRecognizer to multiple views?

Override class by '<UIScrollViewDelegate>'And use this method in .m class:- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer...

View Article


Answer by Joseph Lord for Can you attach a UIGestureRecognizer to multiple...

No you should not attach gesture recognizers to more than one view.There is this explicit information in the Apple documentation:Gesture Recognizers Are Attached to a ViewEvery gesture recognizer is...

View Article


Answer by Dilip Manek for Can you attach a UIGestureRecognizer to multiple...

You can do it using this code my views which are imageviews in the xib.- (void)viewDidLoad{ firstIV.tag = 501; secondIV.tag = 502; thirdIV.tag = 503; forthIV.tag = 504; [self addTapGesturetoImageView:...

View Article

Image may be NSFW.
Clik here to view.

Answer by rohan-patel for Can you attach a UIGestureRecognizer to multiple...

Well if someone does not want to code for adding gesture view for multiple buttons like kwalker has answered above, and want to do it via Interface Builder this may help you.1) You can add Long Press...

View Article

Answer by kwalker for Can you attach a UIGestureRecognizer to multiple views?

I got around it by using the below. for (UIButton *aButton in myButtons) { UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self...

View Article

Answer by TomSwift for Can you attach a UIGestureRecognizer to multiple views?

A UIGestureRecognizer is to be used with a single view. I agree the documentation is spotty. That UIGestureRecognizer has a single view property gives it away:viewThe view the gesture recognizer is...

View Article


Can you attach a UIGestureRecognizer to multiple views?

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTapTap:)];[self.view1 addGestureRecognizer:tapGesture];[self.view2...

View Article
Browsing all 14 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>