我正在处理来自这里的 json 数据,并且必须在 UITableView 中显示数据。
我必须按字母顺序显示部分的内容。每个部分包含多行,每行包含两个标签。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
int section = [indexPath section];
int row = [indexPath row];
UITableViewCell *cell =[[UITableViewCell alloc]init];
UILabel *label1=[[UILabel alloc]initWithFrame:CGRectMake(10, 8, 30, 25)];
label1.font=[UIFont boldSystemFontOfSize:20];
label1.backgroundColor=[UIColor lightGrayColor];
label1.TextAlignment=UITextAlignmentCenter;
label1.textColor=[UIColor whiteColor];
label1.text=[[[[[jsonObject valueForKey:@"leagues"]objectAtIndex:section]valueForKey:@"leagues"]objectAtIndex:row]valueForKey:@"id"];
UILabel *label2=[[UILabel alloc]initWithFrame:CGRectMake(45, 8, 250, 25)];
label2.font=[UIFont systemFontOfSize:18];
label2.backgroundColor=[UIColor clearColor];
label2.text=[[[[[jsonObject valueForKey:@"leagues"]objectAtIndex:section]valueForKey:@"leagues"]objectAtIndex:row]valueForKey:@"league"];
cell.accessoryType=UITableViewCellAccessoryDetailDisclosureButton;
cell.selectionStyle=UITableViewCellSelectionStyleNone;
[cell.contentView addSubview:label1];
[cell.contentView addSubview:label2];
return cell;
}
提前致谢和问候.....