簡體   English   中英

如何將觸摸事件從UIView傳遞到它下面的UIView?

[英]How to pass a touch event from a UIView to the UIView(s) beneath it?

一個簡單的問題,但我無法找到它的解決方案:

我有2個UIViews,在同一個父視圖中一個在另一個之上。 兩者都有GestureRecognizers ,但只有最重要的是接收事件。 如何讓最頂層的視圖通過他獲取到其下面的其他UIViews的所有手勢?

這就是我通過觸摸的方式......

uiview的子類並添加

-(id)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    UIView *hitView = [super hitTest:point withEvent:event];
    if (hitView == self){
        return nil;
    }
    else {
        return hitView;
    }
}

您似乎需要使用NSNotificationCenter來執行上述任務。 看看這個教程

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM