2012-09-24 50 views
0

我想在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

回答

0

自動調整掩碼工作... flexwidth和flexheight

0

試試這個:textView.contentSize = [cell.contentView.frame.size];

+0

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

0

您希望尺寸爲(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