我创建 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];
但我可以更改某些像素和所有像素的高度(
最佳答案
您需要实现 UITableViewDelegate 协议(protocol)才能更改行(单元格)高度。参见方法tableView:heightForRowAtIndexPath: .
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 100.0f;
}
要更改宽度,只需将 UITableView 的宽度设置为所需的值。
关于objective-c - 无法更改 UITableView 中的单元格大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9022263/