我正在将文本视图扩展到其内容大小,如下所示
CGRect _frame = descriptionText.frame;
_frame.size.height = descriptionText.contentSize.height;
descriptionText.frame = _frame;
并且内容超出了视图,无法向下滚动以查看文本。
我尝试像这样设置滚动视图的大小
scrollView.contentSize = CGSizeMake(295,_frame.size.height);
但它无法滚动,但如果我给出这样的数值就可以了
scrollView.contentSize = CGSizeMake(295,600);
我需要将滚动视图的大小设置为动态内容的大小。我怎样才能做到这一点?
编辑 描述文本
CGRect descriptionTextViewRect = CGRectMake(15, 185, 280, 85);
descriptionText = [[UITextView alloc] initWithFrame:descriptionTextViewRect];
descriptionText.textAlignment = UITextAlignmentLeft;
descriptionText.text =offerdes;//this is the text fetched from an xml and is dynamic.
descriptionText.editable = NO;
descriptionText.layer.cornerRadius = 5.0;
descriptionText.clipsToBounds = YES;
descriptionText.userInteractionEnabled = YES;
descriptionText.font = [UIFont systemFontOfSize:15];
[scrollView addSubview: descriptionText];
[descriptionText release];