簡體   English   中英

UITableViewCell內部的UITableView不接收觸摸事件

[英]UITableView inside UITableViewCell not receiving touch events

所以我有一個嵌套在UITableViewCell中的UITableView,例如:

  • UITableView baseTable

    • UITableViewCell baseTableCell0

      • UITableView subTableView
        • UITableViewCell subTableViewCell
      • UIView子視圖
    • UITableViewCell baseTableCell1

      • UICollectionView subCollectionView
        • UICollectionViewCell subCollectionViewCell

subView連接了一個UITapGestureRecognizer,就像按鈕一樣,subTableView和subCollectionView應該接收觸摸事件並執行didSelectRowAtIndexPath

在iOS 8上,它工作正常,但是當我在ios 7上進行測試時,subTableView和subCollectionView中的單元格不再接收觸摸事件,觸摸事件將發送到[baseTableView tableview ... didSelectRowAtIndexPath]。 但是,subView上的UITapGestureRecognizer仍可以接收觸摸事件。

  • 更新:ios 6也有此問題,因此到目前為止,它僅適用於ios 8

在標簽手勢對象上使用此代碼

tap.cancelsTouchesInView = NO;  

嘗試更改UITableView,UITableViewCell和UIView的背景顏色,這樣您就可以查看子視圖是否未超出父視圖,如果子視圖不會接收觸摸事件。 然后,調整“父級”以完全顯示子級,或者調整子級以保留在父級邊界中。

希望能幫助到你!

編輯:

將觸摸事件傳遞給子視圖可能會有所幫助。

暫無
暫無

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

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