我正在使用此代码,但文本视图从子视图外部
CGRect frame = self.dealDetailTextView.frame;
frame.size.height = self.dealDetailTextView.contentSize.height;
self.dealDetailTextView.frame = frame;
CGRect moreViewFrame = self.popUpView.frame;
moreViewFrame.size.height = frame.size.height + 150;
self.popUpView.frame = moreViewFrame;
答案 0 :(得分:0)
- (void)textViewDidChange:(UITextView *)textView
{
CGFloat fixedWidth = textView.frame.size.width;
CGSize newSize = [textView sizeThatFits:CGSizeMake(fixedWidth, MAXFLOAT)];
CGRect newFrame = textView.frame;
newFrame.size = CGSizeMake(fmaxf(newSize.width, fixedWidth), newSize.height);
//Set new frame size and also change popUpView frame base on newFrame
textView.frame = newFrame;
}