UIPanGestureRecognizer on UITableViewCell overrides UITableView's scroll view gesture recognizer

后端 未结 4 1576
终归单人心
终归单人心 2020-12-31 02:26

I\'ve subclassed UITableViewCell and in that class I apply a Pan gesture recogniser:

UIPanGestureRecognizer *panning = [[UIPanGestureRecognizer          


        
4条回答
  •  再見小時候
    2020-12-31 02:52

    Add the gesture recogniser On tableview. From that, you can get the cell object. From there you can handle the cell Functionality. For each gesture, there will be a begin, changed, end state. So, store the begin position.

        CGPoint beginLocation = [gesture locationInView:tblView]; // touch begin state.
    
        CGPoint endLocation = [gesture locationInView:tblView]; // touch end state.
    

    Using this point, you can get the IndexPath

        NSIndexPath *indexPath = [tblView indexPathForRowAtPoint:beginPoint];
    

    From this indexpath, you can access the cell.

                UITableViewCell *cell = [tableview cellForRowAtIndexPath : indexPath];
    

    Using this Cell object, you can handle it.

提交回复
热议问题