I have a UIScrollView, with a UIView in it.
I don't know the size of the subview until everything in it that needs to be displayed has been, and this can change on later drawings. (It has tables, text etc. that are added bit by bit). So, I need to update the scroll view's content size at the point that the subview's drawRect completes.
Is there a good way to trigger the required [myScrollView setContentSize] & [mySubView setNeedsDisplay] (this calls drawRect so I'll take steps to avoid infinite loops) after the drawRect, or any other solution that actually works for this situation?
It seems to need setNeedsDisplay called on the subview before the content size change is acted on. All I have to do is set the setContentSize from the sub-view's drawRect then I press a button that triggers the setNeedsDisplay, the contentSize then refreshes fine. So I could just set a timer and wait for the next run loop to do the setNeedsDisplay? But it's an awful hack. Also I'm guessing resizing the content size in code called from the sub-view's drawRect is a no-no if UIKit relies on the view hierarchy remaining constant while it is in the middle of drawing the view hierarchy.