views:

34

answers:

1

Hi there

If I set UIScrollView height to self.view.frame.size.height and setAutoresizingMask:UIViewAutoresizingFlexibleHeight then when the view loads the UITabBarController and the UINavigationBar the scroll view frame resizes to suit.

However the content size (set at: self.view.frame.size.height) doesn't change. Fair enough I guess - i can't seem to find an autoresizing option for that, so why would it autoresize.

My fix is to just set the content size as less than the frame height, thus the content will always be the height of the frame. (eg: set content size height to 10points).

I'm just wondering if this is the best way to go about this, or if there's a better way? I'm doing this code in viewDidLoad.

Thanks

Tom

+1  A: 

The UIScrollView's contentSize property define the size of the view displayed for Span&Zoom. It normally does not have any relation with the container (i.e. scrollview) size but if you really need to resize the content according to the scrollview size, you can overload the layoutSubViews method to do so.

VdesmedT
ok... thats a good answer. :) is there any way that I can set the content size AFTER the whole view gets displayed? ie: after the navigation bar and tab bar are displayed? ie2: an afterViewDidAppear method or something.
Thomas Clayson
Why would you do something like that instead of resizing it every time the scrollView is resized ?
VdesmedT