Answer the question
In order to leave comments, you need to log in
How do I prevent an event (such as touched) from being passed to the parent Superview?
In general, there is a parent View (Room Scheme View).
There is a child leaving translucent TableView.
Now after tap(select) in TableView, this tap is passed on to the parent View(Room Scheme View)
How to make sure that this tap is not passed to the parent View(Room Scheme View)?
Answer the question
In order to leave comments, you need to log in
The information you provided is not enough. Therefore, a tap cannot simply be transmitted to the parent. Which is exactly what I just checked. Check on which views the tap happens, for example, in this controller method.
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch in touches {
print(touch.view)
}
}
Temporarily solved the problem like this:
RoomSchemeView.h:
/// необрабатываемая зона, в этой области тапы не обрабатываются
@property (nonatomic, assign) CGRect unprocessedRect;
- (void)tap:(UIGestureRecognizer *)gr
{
CGPoint point = [gr locationInView:self];
// проверяем находится ли точка в необрабатываем зоне
if (!CGRectEqualToRect(self.unprocessedRect, CGRectZero) && CGRectContainsPoint(self.unprocessedRect, point)) {
NSLog(@"tap with point %@ in unprocessed rect %@", NSStringFromCGPoint(point), NSStringFromCGRect(self.unprocessedRect));
return;
}
...
}
- (void)showTableView
{
if (!self.tableIsVisible) {
self.tableView.frame = CGRectMake(-self.tableView.frame.size.width, self.tableView.frame.origin.y, self.tableView.frame.size.width, self.tableView.frame.size.height);
[UIView animateWithDuration:.3 animations:^{
self.tableView.frame = CGRectMake(0, self.tableView.frame.origin.y, self.tableView.frame.size.width, self.tableView.frame.size.height);
} completion:^(BOOL finished) {
self.tableIsVisible = YES;
self.roomSchemeView.unprocessedRect = self.tableView.frame;
}];
}
}
- (void)hideTableView
{
if (self.tableIsVisible) {
self.tableView.frame = CGRectMake(0, self.tableView.frame.origin.y, self.tableView.frame.size.width, self.tableView.frame.size.height);
[UIView animateWithDuration:.3 animations:^{
self.tableView.frame = CGRectMake(-self.tableView.frame.size.width, self.tableView.frame.origin.y, self.tableView.frame.size.width, self.tableView.frame.size.height);
} completion:^(BOOL finished) {
self.tableIsVisible = NO;
self.roomSchemeView.unprocessedRect = CGRectZero;
}];
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question