私のアプリケーションでは、私は使用していUITableView
ます
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
このテーブルをスクロールすると、複数のセルに複数のチェックマークが表示されます
私を助けてください..
私のアプリケーションでは、私は使用していUITableView
ます
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
このテーブルをスクロールすると、複数のセルに複数のチェックマークが表示されます
私を助けてください..
このサンプル コードは、tableView のデリゲート メソッド didSelectedRowAtIndexPath で使用できます。
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; [セル setSelected:YES アニメーション:YES]; [セル 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];
一般に、セルは次の 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.
}
セルは再利用キューから来る可能性があるため、構成されました。明らかに、再利用キューからのセルを再構成するのを忘れています。