在我的應用我有UITableView
&我用表格單元格indicater問題
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
,當我滾動此表,然後我得到多個勾選多種細胞
請幫助我..
在我的應用我有UITableView
&我用表格單元格indicater問題
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
,當我滾動此表,然後我得到多個勾選多種細胞
請幫助我..
一般來說,細胞來自2種方式:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identifier = @"Cell";
UITableViewCell *cell = ... // The cell come from reuse queue.
if (cell == nil) {
cell = ... // if reuse queue has no cell, then create an autoreleased cell
}
// Configure cell by indexPath.
// You should configure cell HERE.
}
Bec ause你的單元可能來自重用隊列,它被配置。顯然,你忘記重新配置來自重用隊列的單元。
可以在的tableView的委託方法didSelectedRowAtIndexPath使用此示例代碼
的UITableViewCell *細胞= [的tableView的cellForRowAtIndexPath:indexPath]; [cell setSelected:YES animated:YES]; [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
for(int iterator=0;iterator<3;iterator++)
{
UITableViewCell *eachCell = [[self tableView] cellForRowAtIndexPath:[NSIndexPath indexPathForRow:iterator inSection:0]];
[eachCell setSelected:NO animated:YES];
[eachCell setAccessoryType:UITableViewCellAccessoryNone];
}
UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
[newCell setSelected:YES animated:YES];
[newCell setAccessoryType:UITableViewCellAccessoryCheckmark];
你可以發佈你的代碼嗎?你在哪裏設置單元配件視圖以便更好地理解你的代碼。 – Jhaliya 2011-03-15 08:41:58