テーブルビューがあります。セルで必要なすべてのデータを取得し、更新されたセルを返すメソッドを作成しました。その方法で私は持っています:
行のセルは次のようになります静的NSString*CellIdentifier = @ "Cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
cell = myCellcreationMethod : cell : reuseIdentifier: other arguments;
MycellCreationメソッドは次のようになります。引数を含むMycellCreation、いくつかの文字列、セル、およびreuseIdentifier。
if ( cell == nil ) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
//Here code that creates a custom image view something like:
thumbnailView = [[UIImageView alloc] initWithFrame:CGRectMake(9, 9, 70, 70)];
thumbnailView = [imUtil getImageViewWithRoundedCorners:thumbnailView andRadius:10.0];
thumbnailView.contentMode = UIViewContentModeScaleAspectFit;
[cell.contentView addSubview:thumbnailView];
//same here for another image view,
//same again
//and there same for a UILabel
}
//Here I set in each case the data for each imageView from above and the UIlabel text like
UIImage *thumbnailImage = [imUtil getThumbnailImageWithFile:thumbnail];
thumbnailView.image = thumbnailImage;
//the others go here
textLabel.text = @"something";
return cell;
すべてのセルは同じタイプであるため、すべてのセルは同じ識別子を持っています。しかし、下にスクロールすると、リスト内の次のオブジェクト(新しいサムネイルの新しい画像、uilabelの新しいテキスト)に対応するデータを表示する代わりに、最初のオブジェクトを複製します。再利用されたセルをロードしますが、新しいデータは入れません。
何か提案はありますか?