亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

iOS-通過視圖轉發所有觸摸

iOS-通過視圖轉發所有觸摸

iOS
白板的微信 2019-12-25 15:32:09
我有一個視圖疊加在許多其他視圖之上。我只不過是在檢測屏幕上的某些觸摸而已,但除此之外,我不希望該視圖停止其下的其他視圖(例如滾動視圖)的行為。如何轉發所有觸摸此疊加視圖?它是UIView的子目錄。
查看完整描述

3 回答

?
慕虎7371278

TA貢獻1802條經驗 獲得超4個贊

要將觸摸從疊加視圖傳遞到其下的視圖,請在UIView中實現以下方法:


目標C:


- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {

    NSLog(@"Passing all touches to the next view (if any), in the view stack.");

    return NO;

}

迅速:


override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {

    print("Passing all touches to the next view (if any), in the view stack.")

    return false

}


查看完整回答
反對 回復 2019-12-25
?
長風秋雁

TA貢獻1757條經驗 獲得超7個贊

這是一個舊線程,但是它是在搜索時出現的,因此我想添加2c。我有一個包含子視圖的UIView,并且只想攔截擊中一個子視圖的觸摸,所以我修改了PixelCloudSt的答案


-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event

{

    for (UIView* subview in self.subviews ) {

        if ( [subview hitTest:[self convertPoint:point toView:subview] withEvent:event] != nil ) {

            return YES;

        }

    }

    return NO;

}


查看完整回答
反對 回復 2019-12-25
  • 3 回答
  • 0 關注
  • 599 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號