【发布时间】:2013-10-11 02:06:05
【问题描述】:
我在表格视图之前有一个 UITableViewController 和一个 UIView。 UIView (IBOutlet UIView *templateDescriptionView) 中有一个 UITextView (IBOutlet UITextView *templateDescription)。它看起来像这样:
UITextView 可以有可变数量的文本。我正在尝试以编程方式调整 UITextView 和 UIView 的大小以弥补这一点,但它没有按预期工作。
-(void) viewDidLoad
{
[templateDescription sizeToFit];
CGRect frame = templateDescription.frame;
frame.size.height = templateDescription.contentSize.height;
templateDescription.frame = frame;
CGRect viewFrame = templateDescriptionView.frame;
viewFrame.size.height = templateDescription.contentSize.height + 40; // 40 for padding
templateDescriptionView.frame = viewFrame;
}
问题是,当一切渲染时,UIView 部分位于 UITableView 之上。它调整大小,但没有调整到适当的高度。我究竟做错了什么?这是 Xcode 5,iOS7。
【问题讨论】:
-
你为什么要调整 UITextView 的大小??是不是默认可以滚动的??
-
我希望它填满该区域而无需滚动。
标签: iphone ios uitextview