我在ui控制器上创建了一个“经典”类别,以我的方式呈现另一个控制器。
@interface UIViewController (QZPopup)
- (void)presentPopupViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion;
- (void)dismissPopupViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion;
@end
该类别添加:
对于我的使用情况,我在UIController
中嵌入了UINavigationBarController
。我希望导航栏下方的部分模糊,导航栏可见。触摸模糊视图只需关闭,导航栏上的触摸必须解除并执行导航栏中触摸项目所需的任何操作。
视觉对我来说没问题,但我无法通过该事件并到达导航栏。目前,我已在[{1}}中将UIView
子类化为如下所示:
QZPopupDismiss
但事实是,在@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
中,touchsEnded
未到达导航栏。如何将事件传递到整个视图层次结构以到达导航栏项?