-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文件
聲明變量