1

私は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ます。ナビゲーションバーの下の部分をぼかして、ナビゲーションバーを見えるようにしたいです。ぼやけたビューへのタッチは閉じるだけで、ナビゲーション バーへのタッチは閉じて、ナビゲーション バー内のタッチされたアイテムに必要な処理を実行する必要があります。

私の側ではビジュアルは問題ありませんが、イベントを渡してナビゲーションバーに到達するのに問題があります。とりあえず、以下のようにサブクラス化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ナビゲーションsuperバーに到達していません。ビュー階層全体にイベントを渡して、ナビゲーション バーの項目に到達するにはどうすればよいですか?

4

0 に答える 0