简体   繁体   中英

UITableView inside UITableViewCell not receiving touch events

So I have a UITableView nested inside a UITableViewCell, like:

  • UITableView baseTable

    • UITableViewCell baseTableCell0

      • UITableView subTableView
        • UITableViewCell subTableViewCell
      • UIView subView
    • UITableViewCell baseTableCell1

      • UICollectionView subCollectionView
        • UICollectionViewCell subCollectionViewCell

subView has a UITapGestureRecognizer connected, acts like a button subTableView and subCollectionView should receives touch events and perform didSelectRowAtIndexPath

On iOS 8 this works fine, but when i'm testing on ios 7 the cells in subTableView and subCollectionView does not receives touch event anymore, the touch event is sent to [baseTableView tableview... didSelectRowAtIndexPath]. However the UITapGestureRecognizer on subView can still receive touch event.

  • update: ios 6 has this problem as well, so it only works on ios 8 so far

在标签手势对象上使用此代码

tap.cancelsTouchesInView = NO;  

Try changing the background color of your UITableView, UITableViewCell and UIView, this way you can see if your child view is not exceeding your parent view, if it is the case your child view is not going to receive touch events. Then either adjust Parent to show child fully or adjust child to remain in the parent boundary.

Hope it helps!

EDIT:

May be passing touch events to subviews can help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM