セパレータースタイルに UITableViewCellSeparatorStyleSingleLine を使用して 'UITableViewStylePlain' として構成された UITableView があります。セルには背景色があります。
問題は、テーブルビューをスクロールすると、一部のセルが画面から消えて元に戻ると、セパレーターが表示されなくなることです。
セルは次のものに登録されます。
[tableView registerNib:nib forCellReuseIdentifier:cellIdentifier];
セル コード:
- (void)customizeMyTable
{
[self.tableView setDataSource:self];
[self.tableView setDelegate:self];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
NSString *cellIdentifier = [MyTableViewCell cellIdentifier];
UINib *nib = [UINib nibWithNibName:cellIdentifier bundle:nil];
[self.tableView registerNib:nib forCellReuseIdentifier:cellIdentifier];
self.tableView.rowHeight = 50;
}
- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyTableViewCell *cell = (MyTableViewCell*)[tableView dequeueReusableCellWithIdentifier:cellID];
[cell configure:someDataForThisRow];
return cell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.backgroundColor = [UIColor lightGrayColor];
}
誰でもこの問題が発生しますか? これは、iOS 6 のテーブルビューではなく、iOS 5 でのみ発生するようです。