开发者

How to have a scrollview take the space between the uinavigationbar and the uitoolbar

I have a scrollview that I had to the view of the view controller pushed to a UINavigationController. My navigation bar is opaque.

However, the scrollview seems to keep size of the whole parent view. I would like the scrollview to have the size of the space between the toolbar and the navigationbar.

Is this possible or do I have to hardcode some size values?

Thanks in adva开发者_开发技巧nce


When you initialize your scrollView you can set its contentSize parameter:

 [scrollView setContentSize:CGSizeMake(320,392)];

The height of the screen (480) minus the toolbar (44) and navigation bar (44) = 392. Drop that to 372 if you're also displaying the carrier status bar.

or, use the frame geometry properties:

[scrollView setContentSize:CGSizeMake((scrollView.superview.frame.size.width),
                                      (scrollView.superview.frame.size.height -
                                       toolbar.frame.size.height - 
                                       navigationController.navigationBar.frame.height))];


When you use autosize, the correct frame size is not known on viewDidLoad. You should pack this inside viewWillAppear and then everything works fine

scrollView.contentSize = CGSizeMake(scrollView.superview.frame.size.width, scrollView.superview.frame.size.height);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜