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);
这篇博客介绍了在Swift中如何在点击UITableView的Cell时获取当前选中的Cell。通过`indexPathForSelectedRow`方法可以获取选中行的IndexPath,并通过`cellForRowAtIndexPath`获取对应的Cell对象,从而进行进一步操作,例如修改Cell的文字内容。
5343

被折叠的 条评论
为什么被折叠?



