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

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

$
0
0

We can do something Like this, it's easy and simple

1) create function as below in your controller (this function will return GestureRecognizer)

-(UITapGestureRecognizer*)setRecognizer{     UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openProfile)];     [gestureRecognizer setNumberOfTapsRequired:1];     return gestureRecognizer;}

2) now set this recognizer in multiple views

[self.view1 addGestureRecognizer:[self setRecognizer]]; [self.view2 addGestureRecognizer:[self setRecognizer]];

Viewing all articles
Browse latest Browse all 14

Trending Articles



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