无法在UITableView中更改单元格大小

时间:2012-01-26 17:14:11

标签: objective-c ios ipad uitableview

我创建tableViewController并需要使最后一个单元格更大。但我不能按我的意愿设定尺寸。这是我的代码

cell.bounds = CGRectMake(0,45,320,900);
        [[cell.contentView viewWithTag:indexPath.row]removeFromSuperview] ;
        CGRect frame = CGRectMake(20, 20, 400, 500);
        CGRect frame2 = CGRectMake(0, 0, 400, 500);
        [cell setFrame:frame];
        [cell setBounds:frame2];

        //[self tableView].rowHeight = 500;
        UITextView *txtView = [[UITextView alloc] initWithFrame:frame];
        txtView.text = @"SEND FROM MY IPAD";
        txtView.textAlignment = UITextAlignmentLeft;
        [cell.contentView addSubview:txtView];
        [txtView release];

但我可以更改某些像素和所有(enter image description here

的高度

1 个答案:

答案 0 :(得分:1)

您需要实现UITableViewDelegate协议才能更改行(单元格)高度。请参阅方法tableView:heightForRowAtIndexPath:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100.0f;
}

要更改宽度,只需将UITableView的宽度设置为所需的值。

相关问题