1. 程式人生 > >點選tableview後要獲取當前點選的cell

點選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);