0
我想創建一個UITableView積分榜。UITableViewCell標籤調整大小,當我滾動
我創建了一個自定義單元格,帶有7個標籤。我已經使用編組單元中美聯中區,國聯東區等
退房這一形象,以區分當我加載的觀點:
比較與圖像,當我滾動視圖:
這裏是我的代碼(去掉重複的代碼):
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = @"Cell2";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}// end
//rank
UILabel *rank = (UILabel *)[cell viewWithTag:101];
//team
UILabel *team = (UILabel *)[cell viewWithTag:102];
if(indexPath.row == 0)
{
NSArray *division = @[@"AL Central", @"AL East", @"AL West", @"NL Central", @"NL East", @"NL West"];
rank.text = @"";
team.text = division[indexPath.section];
cell.backgroundColor = textPrimary;
team.textColor = backgroundPrimary;
team.font = [UIFont boldSystemFontOfSize:5.0f];
won.font = [UIFont boldSystemFontOfSize:11.0f];
return cell;
}
cell.backgroundColor = [UIColor clearColor];
rank.textColor = textPrimary;
team.textColor = textPrimary;
int new_row = indexPath.row + indexPath.section*5 - 1;
rank.text = [[[dataSource objectAtIndex:new_row] objectForKey:@"rank"] stringValue];
team.text = [[dataSource objectAtIndex:new_row] objectForKey:@"first_name"];
return cell;
}