我已經在這個問題上幾個星期了。(自定義)滾動後UITableViewCell的混合
基本上當我向上滾動的TableView塔爾中/下使用在IB設計了一個自定義單元格的所有內容都混合起來,放錯地方的
香港專業教育學院嘗試多種解決方案,但都無濟於事,你要去必須原諒我的代碼一點點。
人們總是建議爲表格單元格創建一個子視圖,但我不知道該怎麼做= /對於iOS開發還是一個相當新的東西,所以如果你有一個可能的答案,你能否儘可能的詳細說明一下。
再次,對不起,我的代碼=/
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:MyIdentifier];
NSInteger intCellTag;
NSDictionary *dictionary = [[[self.tableDataSource objectAtIndex: indexPath.section] objectForKey: @"Rows"] objectAtIndex: indexPath.row];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
[[[NSBundle mainBundle] loadNibNamed:@"EventsCustomTVCell" owner:self options:nil] lastObject];
cell = tvCell;
self.tvCell = nil;
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.tag = intCellTag;
intCellTag++;
UIImage *customCellBG = [UIImage imageNamed:@"EventsCustomTableCellBG.png"];
UIImageView *customCellBGImageView = [[UIImageView alloc] initWithImage: customCellBG];
customCellBGImageView.contentMode = UIViewContentModeScaleToFill;
cell.backgroundView = customCellBGImageView;
[customCellBGImageView release];
[cell.contentView addSubview:imgThumbnail];
[cell.contentView addSubview:lblName];
[cell.contentView addSubview:lblDescription];
[cell.contentView addSubview:lblDate];
}
imgThumbnail.image = [UIImage imageNamed:[dictionary objectForKey: @"Thumbnail"]];
lblName.text = [dictionary objectForKey:@"Title"];
lblDescription.text = [dictionary objectForKey:@"Description"];
lblDate.text = [dictionary objectForKey:@"Date"];
return cell;
}
這工作就像一個魅力! – Andyy 2011-02-18 02:54:49