我是iPhone開發新手。我正在開發一個應用程序,其中包含單元格內的標籤tableview。我已經爲每一行放置了不同的標籤,就像這樣,對於每個細胞行我都這樣做了。但是當我滾動tableview時,我的標籤變得混雜了。請幫幫我!如何控制我的tableview單元格標籤?
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
if (indexPath.row == 2)
{
pendingListNumberLabel = [[UILabel alloc] init];
pendingListNumberLabel.font = [UIFont fontWithName:@"Helvetica" size:14];
pendingListNumberLabel.textAlignment = UITextAlignmentLeft ;
pendingListNumberLabel.textColor = [UIColor orangeColor];
pendingListNumberLabel.frame = CGRectMake(240, 6, 110, 30);
[pendingListNumberLabel setBackgroundColor:[UIColor clearColor]];
[cell addSubview:pendingListNumberLabel];
}
cell.textLabel.text = [affiliationsArray objectAtIndex:indexPath.row];
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
return cell;
後...你....代碼! – borrrden
多一點解釋和一些代碼wud幫助我們更好地幫助你。 :) –
如果沒有看到代碼,我會認爲你使用的是不正確的重用標識符。 –