1

我需要显示单元格数据。实际上,如果我调试代码,我可以看到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;
}
4

1 回答 1

0

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

于 2013-03-25T01:05:57.453 回答