1

I have created a "classic" category on ui controller to present in my way an other controller.

@interface UIViewController (QZPopup)
- (void)presentPopupViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion;
- (void)dismissPopupViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion;
@end

The category adds:

  • a blurred view on top of the calling controller view
  • an invisible view on top of all the screen. this invisible view must catch touch event to dismiss the popup and after having dismissed the popup, I also want to transmit this event to do anything required.

For my usage, I have a UIController embedded in a UINavigationBarController. I want to have the part below the navigation bar blurred and the navigation bar visible. A touch on the blurred view just dismiss and a touch on the navigation bar must dismiss AND do anything required by touched items in the navigationbar.

Visual is ok on my side, but I have trouble to pass the event and reach the navigationbar. For the moment I have subclassed UIView in QZPopupDismiss like below:

@implementation QZPopupDismiss {
    touchCallback _touchCompletion;
}

- (instancetype)initWithFrame:(CGRect)frame andTouchCompletion:(touchCallback)completion {
    if (self = [self initWithFrame:frame]) {
        _touchCompletion = completion;
        self.userInteractionEnabled = YES;
    }
    return self;
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

    // first do the touch completion
    _touchCompletion();

    // pass the event to the view hierarchy
    [super touchesEnded:touches withEvent:event];
}
@end

But the fact is that, in touchsEnded, super does not reach the navigation bar. How can I pass my event to the whole view hierarchy to reach the navigation bar items ?

chepiok
  • 193
  • 12

0 Answers0