I want to hidden some contents when touching anywhere in the View. I have a view and some labels and view as subview , If I add tap gesture for the main view, all the subview get respond? or I have to add tap gesture for each subview separately?
Asked
Active
Viewed 67 times
1 Answers
0
You could add touchesBegan:withEvents:
inside your main UIView
. Every time you touch an element inside the UIView
you can get the selected element from the touch and also set it hidden:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesBegan:touches withEvent:event];
UITouch *touch = [[event allTouches] anyObject];
touch.view.hidden = YES;
}

Alex Cio
- 6,014
- 5
- 44
- 74