variable height views
Hello,
I have worked on this for 2 days and I know it is possible as I have seen it in other applications, but at this point not sure that I can recreate it. Here is what I am trying to do:
UIViewController with a UIView. In the UIView I have:
Label
-Text
The height of the text under the label can vary so depending on the height of the text I need it to scroll down to show all of the text. If the text is short enough, then I there is no need to scroll. Because if it did, then you would scroll down to a blank view (all the text scrolls off the screen). What I'd like to have happen is to find the height of the text and then adjust the scroll view accordingly. I have been able to get this to work thus far:
CGSize size = [detailDescription contentSize];
What this does is gets the contentSize of my uitextview (easy enough). It took me a bit, but I got it to output the correct value when I put it in my viewDidAppear method. It shows me the variable height of the text. So, next I tried to set the height and width of my UIScrollView as follows:
detailScrollView.contentSize = CGSizeMake(320, size.height);
This didn't work as I am assuming the view was already drawn and it wasn't going to go back and recreate my UIScrollView. So, I am completely lost at this point after much searching and testing. I think I may just leave it as a bad user experience with text scrolling off to oblivion, but wanted to check with others if they had an idea.
My requirements are just:
a label at the top
under this have a UITextView or Label (just something that can pull in data)
and then have a variable height depending on the text height.
thanks for any help
Mike
|