我没有iOS6的这个问题,但我目前正在使用iOS7。我有一个UITableView,你可以在加载视图时看到8个单元格。每个人都使用和数组中的不同名称进行填充。如果向下滚动,接下来的两个单元格看起来不错,但过去的所有内容都会将文本放在顶部;该文本是以前单元格中的内容。所以第10个单元格将具有第一个单元格中的内容,以及第10个单元格中应该放置的内容。UITableView单元内的UILabels在iOS7中彼此重叠
代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
//Create Label for Name inside cell
UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake(7.0, 5.0, 300.0, 30.0)];
[name setText:[self.entriesArray objectAtIndex:indexPath.row]];
//Check to see if current person is a Parent or Child
NSString *class = [self.database getCellDataWithMembership:[self.MembershipArray objectAtIndex:indexPath.row] andColIndex:4];
if([class isEqualToString:@"CHILD"])
{
name.textColor = [UIColor colorWithRed:25.0f/255.0f green:111.0f/255.0f blue:45.0f/255.0f alpha:1.0f];
name.font = [UIFont fontWithName:@"Helvetica-Bold" size:17.0];
}
[cell.contentView addSubview:name];
return cell;
}
我与表视图技能是临时的最好的。我一直在阅读大量文档和研究解决方案,但无法提出解决方案。我觉得很奇怪,它适用于iOS6,但不适用于iOS7。
因此,它从一个数组中提取一个人的名字,我想用这些名字填充单元格。我能原本做到这一点使用:
cell.textLabel.text = [self.entriesArray objectAtIndex:indexPath.row];
if([class isEqualToString:@"CHILD"])
{
cell.textLabel.textColor = [UIColor colorWithRed:25.0f/255.0f green:111.0f/255.0f blue:45.0f/255.0f alpha:1.0f];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17.0];
如果我用这个来代替“名称”的UILabel从第一个代码块的行为,那么它完全没有文字叠加显示的名字,但什么成为一个问题是文字颜色。如果他们被标记为儿童,那么他们应该是绿色文字和粗体。但是,滚动后,每个人都不会变绿。
对不起,冗长的问题。我一直在研究这个问题,并围绕它大肆渲染我的大脑,我似乎无法弄清楚。任何帮助将不胜感激。
很抱歉,但是这无关我的问题。我知道你在说什么,但这是无关紧要的。我有一个UITableView中的单元格,它们基本上是相互重复的。 Delta的值可能不会解决这个问题:( – lshaffer