我沒有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