how can I distinguish which part of UITableViewCell has been clicked

前端 未结 5 1627
伪装坚强ぢ
伪装坚强ぢ 2020-12-04 22:33

I have created a UITableView with a custom UITableViewCell. My cell includes one UIImageView on the left and UITextView o

5条回答
  •  遥遥无期
    2020-12-04 23:20

    you have two option is to implement :- 1--add UITapGestureRecognizer in your "uitableviewcell" and make it point to image view and pass "indexpath" as parameter to selector and make the delegate pass it to tableviewcell

    UILabel *label = =[UILabel alloc]init];
    label.userInteractionEnabled = YES;
    UITapGestureRecognizer *tapGesture =
    [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelTap)]     autorelease];
    [label addGestureRecognizer:tapGesture];
    
    
    -(void)labelTap{
    [delegate performselector@selector(labeltapped:)withobject:indexpath];
    }
    

    2- Second way is to check the sender of DidSelectRowAtIndexPath of type [imageview or label]; but i prefer the first way

提交回复
热议问题