點選tableview後要獲取當前點選的cell
阿新 • • 發佈:2019-02-04
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);