开发者

UIScrollView.size = view.size - allAdditionalBars.size (like TabBar or NavigationBar) programmatically

开发者 https://www.devze.com 2023-03-25 18:58 出处:网络
UIScrollView is set programmaticall开发者_如何转开发y, please dont post answers with using .xib file.

UIScrollView is set programmaticall开发者_如何转开发y, please dont post answers with using .xib file.

My UIScrollView is situated in my model class, so i want the code to be able to be easly imported to another project eg. for iPad or with rotating screen.

I have a view:

self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width;, self.view.frame.size.height;)];

And my UIScrollView. I want to set it's size to cover all screen not counting all bars that my controller class will have. But i dont know how ;)

I though about subtracting self.view.frame.size.height - self.navigationController.navigationBar.frame.height and self.tabBarController.tabBar.height if each exists.

Is there any method that automatically sets UIScrollView size..?

Thank you in advance!


In your UIViewController subclass, you don't need to worry about the size of any UINavigationController or UITabBarController chrome. Those controllers will automatically resize your controller's main view to fit the appropriate content area.

If I'm creating the UIView myself in the controller's loadView, I usually just initially size it at [[UIScreen mainScreen] applicationFrame]. If I were to add a UIScrollView as a subview that would fill up the entire area of the main view (rather than just using the UIScrollView directly as the main view), I would use self.view.bounds as its frame and be sure to set autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;.

0

精彩评论

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

关注公众号