UITableView中的UITextView iPad

UITableView中的UITextView iPad

问题描述:

我想在iPad的UITableViewCell中添加UITextView,出于某种原因,我的UITextView没有占用整个UITableViewCell的高度/宽度。以下是我声明细胞UITableView中的UITextView iPad

UITextView *textView = [[UITextView alloc]initWithFrame:cell.frame]; 
[textView setBackgroundColor:[UIColor redColor]]; 
[cell.contentView addSubview:textView]; 

虽然它看起来像事先此 enter image description here

感谢。

+0

您是否尝试过使用'cell.contentView.frame'? – Ravi

+0

是的,它不起作用 – VTS12

+0

当您打印该框架时的结果是什么? – Ravi

自动调整掩码工作... flexwidth和flexheight

试试这个:textView.contentSize = [cell.contentView.frame.size];

+0

UITextView * textView = [[UITextView alloc] initWithFrame:cell.contentView.frame]; textView.contentSize = cell.contentView.frame.size;没有工作...结果是相同的 – VTS12

您希望尺寸为(cell.contentView.frame.size.width,cell.contentView.frame.size.height),原点为(0,0)。 然后将其添加到cell.contentView。框架的起源是相对于textView的超级视图,在这种情况下,它将是cell.contentView。

+0

textView.frame = cell.contentView.frame不起作用...结果是一样的 – VTS12

+0

您是否将原点设置为0,0?我认为这是你需要的改变 – geraldWilliam