希望有人可以告诉我正确的方法来填充UITableViewCell自定义标签.我一直遇到同样的问题,标签是空白的,或者表格填满cells重复使用的表格显示重叠label文本.
我已经按照这里为其他人提供的建议,但每次我做的事情都会中断.
**更新**
我已将代码更改为以下并且大部分工作都有效,除非我选择一个标签重叠的单元格,如下面的屏幕截图所示.我正在使用的教程的代码可以在这里找到:https://github.com/funkyboy/Core═-on-iOS-5-Tutorial--How-To-Work-with-Relations-and-Predicates
这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
FailedBankInfo *info = [_fetchedResultsController objectAtIndexPath:indexPath];
CGRect infoFrame = CGRectMake(10, 10, 200, 16);
UILabel *infoLabel = [[UILabel alloc] initWithFrame:infoFrame];
infoLabel.textColor = [UIColor blackColor];
infoLabel.backgroundColor = [UIColor yellowColor];
infoLabel.font = [UIFont systemFontOfSize:12];
infoLabel.textAlignment = NSTextAlignmentCenter;
infoLabel.tag = indexPath.row;
infoLabel.text = [NSString …Run Code Online (Sandbox Code Playgroud)