nek023/QBPopupMenu

detecting touches outside the parent view

Opened this issue · 0 comments

screen shot 2014-03-05 at 4 41 33 pm

In case anyone is interested, I was able to figure out how to use QBPopupMenu when it extends beyond the boundary of the parent view. In my case, it was for a UITextView positioned below a UITableView.

The important trick is that you need to have a common parent UIView that contains the view displaying the popup menu, as well as any views that it overlaps. The parent view needs to have access to the popup menu, so you'll need to allocate it there, or use a singleton. Then, override hitTest in the parentView:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    if ([_popupMenu isVisible]) {
        CGPoint localPoint = [self convertPoint:point toView:_popupMenu];
        UIView * view = [_popupMenu hitTest:localPoint withEvent:event];
        if (view)
            return view;
    }
    return [super hitTest:point withEvent:event];
}

There is no issue here, unless you want to add an example to the Demo. :)