开发者

How to make an action by clicking on ScrollView in Tableview Customcell

I have a tableview and i'm using CustomCell for that tableview. I have imageview, label, and ScrollView in that customcell. But my problem is, after clicking image or label that particular cell is selected and then navigating to the detailView. But on cl开发者_Python百科icking scrollview, cell is not selected. How to solve my problem.? Please help me out, Thanks in advance.

My custom cell like below:

How to make an action by clicking on ScrollView in Tableview Customcell


Solution 1

When clicking on the scroll view, cell is not selected because the scroll view receives the touches, not the cell. If you want the cell to receive touches you need to explicitly set,

scrollView.userInteractionEnabled = NO;

which will make the scrollView irresponsive to touches, and I hope that is not what you want.

Solution 2

I think you are not doing anything with the scrollView when you tap on it. If so, add a UITapGestureRecognizer to the scrollView and in the tap action do the operation that you do in didSelectRowAtIndexPath: method.

- (void)handleSingleTap:(UITapGestureRecognizer *)tap { 

    UIScrollView *scrollView = (UIScrollView *)tap.view;
    UITableViewCell *cell = (UITableViewCell *)scrollView.superview.superview;
    NSIndexPath *indexPath = [_tableView indexPathForCell:cell];

    [self tableView:tbl_view didSelectRowAtIndexPath:indexPath]; 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜