点击tableview后要获取当前点击的cell

1.点击cell获取当前的cell

NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; cell.textLabel.text= @"abc";

2。

  NSIndexPath *myIndex=[self.tableView indexPathForCell:(UITableViewCell*)[bt superview]];  

//如果按钮是加在cell上的contentView上 

    NSIndexPath *myIndex=[self.tableView indexPathForCell:(UITableViewCell*)[[bt superview]superview]]; 

    NSLog(@"myIndex.section==%ld",myIndex.section); 

    NSLog(@"myIndex.row==%ld",myIndex.row); 


猜你喜欢

转载自blog.csdn.net/wanglei0918/article/details/80059379