たとえば、テーブル ビューの最初のセルの背景色を青に設定しようとしていますが、うまくいきません。スクロールを開始するたびに、青色が別のセルにジャンプします。私はこれらのコードを試しました。
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if([[self.menu objectAtIndex:indexPath.row] isEqual:@"a string"]){
cell.contentView.backgroundColor=[UIColor blueColor] ;
}
}
と
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row==0){
cell.contentView.backgroundColor=[UIColor blueColor] ;
}
}
そして、インデックスパスのcellfro行でも試しました。何か足りない?
これは私が cellforrowatindexpath に使用しているコードです:
if(indexPath.row==0){
cell.contentView.backgroundColor=[UIColor blueColor] ;
}