【发布时间】:2010-01-12 15:31:12
【问题描述】:
我见过很多人遇到类似的问题,但他们的解决方案要么没有帮助,要么太不一样了。
我的问题是,我有一个自定义的 UITableViewCell、自定义大小、图像和内容。当我向上或向下滚动然后再次返回时,某些单元格中的文本会消失。这似乎是随机发生的。
我已阅读有关“出队”问题的信息,但要么我弄错了,要么它不属于我的情况......
无论如何,这是我的 Cells 的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.imageView.image = [[UIImage alloc] initWithContentsOfFile:
[[NSBundle mainBundle] pathForResource:
[[shopItems objectAtIndex:indexPath.row] name] ofType:@"jpg"]];
UITextField *temp= [[UITextField alloc] initWithFrame:cell.frame];
temp.text = [[shopItems objectAtIndex:indexPath.row] name];
temp.textColor = [UIColor whiteColor];
temp.textAlignment = UITextAlignmentCenter;
UIImageView *cellView = [[UIImageView alloc] initWithImage:[[UIImage alloc] initWithContentsOfFile:
[[NSBundle mainBundle] pathForResource:@"smalltabs_wide_bg" ofType:@"png"]]];
[cellView addSubview:temp];
cell.backgroundView = cellView;
return cell;
}
您对此有任何(!)想法吗?
【问题讨论】:
标签: iphone uitableview