自定义单元格数据未显示ios

时间:2013-03-24 23:25:16

标签: ios uitableview

我需要显示单元格数据。实际上,如果我调试代码,我可以看到cell.label.text确实有正确的值,但模拟器上没有显示任何内容。我在numberOfRowsInSection方法中设置了行计数。

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
        static NSString *identifier = @"Cell";
        LogTableCell *cell = (LogTableCell *)[tableView dequeueReusableCellWithIdentifier:identifier];
        CGRect frame1 = [ self.view  frame];
        frame1.origin.x=22.0f;
        frame1.origin.y=55.0f;

        frame1.size.width = 298.0f;
        frame1.size.height= 425.0f;
        [self.view.superview setFrame:frame1];
        int btnWidth = ((self.view.frame.size.width-16)/3);


        if(cell == nil)
        {
            cell = [[LogTableCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        }
        LogItem *lg = [[LogItem alloc]init];

        lg = [arrLogs objectAtIndex:indexPath.row ];

        NSLog(@"%d",indexPath.row);
        cell.lblname.textColor=[UIColor whiteColor];
        cell.lblsubtype.textColor=[UIColor whiteColor];
        cell.lbltime.textColor=[UIColor whiteColor];
        cell.lblname.font=[UIFont fontWithName:@"Merriweather" size:15.0];
        cell.lblsubtype.font=[UIFont fontWithName:@"Merriweather-Light" size:13.0];
        cell.lbltime.font=[UIFont fontWithName:@"Merriweather-Light" size:13.0];

        UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(1, cell.contentView.frame.size.height, 298.0,2)] ;

        imageview.image = [UIImage imageNamed: @"lineseperator.png"];
        [cell.contentView addSubview:imageview];

        cell.lblname.text = lg.name;
        NSLog(@"%@",lg.name);
        [[cell imgtype] setImage:[UIImage imageNamed:lg.imagetype]];

        if([lg.subtype length] == 0){
            NSLog(@"%@",lg.subtype);
            cell.lblsubtype.text = lg.time;
            cell.lbltime.text = @"";
        }
        else{
            NSLog(@"%@",lg.subtype);
            cell.lblsubtype.text = lg.subtype;
            cell.lbltime.text = lg.time;
        }


    return cell;
}

1 个答案:

答案 0 :(得分:0)

您要添加到单元格的imageview将涵盖所有其他内容。您需要调整大小/重新定位它,或者只使用已经存在的cell.imageView。