Ios 在整个视图层次结构上传递事件

Ios 在整个视图层次结构上传递事件,ios,uiview,uiviewcontroller,uiview-hierarchy,Ios,Uiview,Uiviewcontroller,Uiview Hierarchy,我在ui控制器上创建了一个“经典”类别,以我的方式呈现另一个控制器 @interface UIViewController (QZPopup) - (void)presentPopupViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion; - (void)dismissPopupViewControllerAnimat

我在ui控制器上创建了一个“经典”类别,以我的方式呈现另一个控制器

@interface UIViewController (QZPopup)
- (void)presentPopupViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion;
- (void)dismissPopupViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion;
@end
该类别增加了:

  • 调用控制器视图顶部的模糊视图
  • 所有屏幕上方的不可见视图。这个不可见的视图必须捕获touch事件来关闭弹出窗口,在关闭弹出窗口之后,我还想传输这个事件来执行任何需要的操作
对于我的使用,我在
UINavigationBarController
中嵌入了
UIController
。我想让导航栏下面的部分模糊,导航栏可见。在模糊视图上的触摸只需关闭,在导航栏上的触摸必须关闭,并执行导航栏中被触摸项目所需的任何操作

我这边的视觉效果还可以,但我很难通过活动并到达导航栏。目前,我在
qzPopupDisease
中对
UIView
进行了子类化,如下所示:

@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
但事实是,在触摸屏中,
super
无法到达导航栏。如何将事件传递到整个视图层次结构以访问导航栏项目