简体   繁体   中英

Can not change cell size in UITableView

I create tableViewController and need to make the last cell bigger. But I can't to set the size as I want. Here My code

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];

But I can change height for some pixels and all( 在此处输入图片说明

You need to implement UITableViewDelegate Protocol in order to change row (cell) height. See method tableView:heightForRowAtIndexPath: .

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

To change width just set UITableView's width to required value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM