-2
当我点击表格视图单元格时,我需要更改另一个单元格的详细标签文本。 我该怎么做?当选择其中一个时,更改其他表格视图单元格的数据
当我点击表格视图单元格时,我需要更改另一个单元格的详细标签文本。 我该怎么做?当选择其中一个时,更改其他表格视图单元格的数据
您需要为所选行存储indexPath。你可以把条件放在cellForRow左右。
这里是排序例如:
int selectedIndexPath;
的.m
-(void)viewDidLoad
{
[super viewDidLoad];
// So it won't show any select for the first time
selectedIndexPath = -1;
[tableView reloadData];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
int currentRow = (int)indexPath.row;
if(currentRow == selectedIndexPath)
{
// Show your base cell
}
else
{
// Show detail cell
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
selectedIndexPath = (int)indexPath.row;
[tableView reloadData];
}
:在h文件
声明变量