Hey, I want to be able to check if user touches my UIView so I can dismiss my picker how can I do it actually? Thanks!
Try adding a UITapGestureRecognizer
to your UIView
class in the viewDidLoad
of the UIViewController
subclass that contains your UIView
. It would look something like this:
- (void)viewDidLoad {
[super viewDidLoad];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];
tap.numberOfTapsRequired = 1;
[self.aView addGestureRecognizer:tap];
[tap release];
}
Then implement a handler for the tap which, based on the above code, would look like this:
-(void)viewTapped:(UITapGestureRecognizer *)recognizer {
//Add in your picker dismissal code here
}
Hope this helps,
Justin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With