您的位置:首页 > 产品设计 > UI/UE

tableviewcell重绘

2013-11-27 16:20 369 查看
NSString *CellIdentifier =[NSString stringWithFormat:@"Cell-%d-%d",indexPath.section,indexPath.row]; // [NSString stringWithFormat:@"cell%@", code];

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    

    if (cell == nil) {

        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

        cell.backgroundView = nil;

     }

    int  sect = [indexPath section];

    int row =[indexPath row];

    

    NSDictionary *dic = [contentArray objectAtIndex:sect];

//    NSLog(@"dic --- %d   = %@",sect, [dic objectForKey:@"Code"]);

    cell.selectionStyle = UITableViewCellSelectionStyleNone;

//    NSLog(@"---section =%d----row=%d",sect,row);

    switch (row) {

        case 0:

        {

            UILabel *label1 =(UILabel *)[cell viewWithTag:sect*10+100];

            if (label1 == nil) {

                label1 = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, __MainScreen_Width/2, 44)];

                label1.backgroundColor = [UIColor clearColor];

                label1.font = [UIFont systemFontOfSize:12.0f];

                label1.tag =100 +sect*10;

                label1.textAlignment = NSTextAlignmentLeft;

                [cell addSubview:label1];

            }

//            NSLog(@"-----label1.tag  =%d",label1.tag);

            UILabel *label2 =(UILabel *)[cell viewWithTag:101 + sect*10];

            if (label2 == nil) {

                label2 = [[UILabel alloc] initWithFrame:CGRectMake(__MainScreen_Width/2, 0, __MainScreen_Width/2-15, 44)] ;

                label2.backgroundColor = [UIColor clearColor];

                label2.font = [UIFont systemFontOfSize:12.0f];

                label2.tag =101 + sect *10;

                label2.textAlignment = NSTextAlignmentRight;

                [cell addSubview:label2];

            }

//            NSLog(@"-----label2.tag  =%d",label2.tag);

            label1.text = [NSString stringWithFormat:@"%@",[dic objectForKey:@"Code"]];

            label2.text = [dic objectForKey:@"Integral"];

        }

            break;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  移动 uitableviewcell