开发者

UIScrollView autoresizing content?

开发者 https://www.devze.com 2023-01-19 15:35 出处:网络
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

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 alway开发者_JS百科s 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消