-1
我有一個表格視圖。我創建了一個方法,它將所有需要的數據提供給單元格並返回更新後的單元格。在該方法中,我有:iPhone可重用單元格在滾動時不顯示更改的數據
我對行單元格是這樣的 靜態的NSString * CellIdentifier = @「細胞」;
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
cell = myCellcreationMethod : cell : reuseIdentifier: other arguments;
MycellCreation方法是這樣的: MycellCreation與ARGS一些字符串,細胞和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中的新文本),而是複製第一個對象。我想它會加載重複使用的單元格,但不會放入新的數據。
有什麼建議嗎?
你用故事板嗎?如果是,你是否在表視圖的屬性檢查器中將表視圖的內容設置爲動態原型和原型單元格爲1。我想這些也可以通過編程來設置。 – tiguero