How to prevent subview from overlapping tab bar?

不羁岁月 提交于 2020-01-03 17:10:27

问题


I have a view with tab bar at the bottom. This view is pushed on a navigation controller, so there is also a navigation bar at the top. Unto this view, I would like to show a table view, which I create from its own nib. When I add this view as a subview, it overlaps the tab bar.

Is there a way to make this subview automatically resize to the free space in between the top and bottom bar?

If not, what is the 'right' way of adjusting its size to fit?

-Vegar


回答1:


In the interface builder make sure that you've set the navigation bar and tab bar spacers up. It should be the first list of options on the first tab in the Interface builder Properties view. This will make your view mimic the amount of space it has when loaded in the view.

From there you can also choose the option to clip the subview. The interface builder also allows you to set resize options for the view. If the subview your adding wasn't created in the interface builder you'll have to specify those options manually.

Lastly make sure that your appending the subview to the correct view, and not the tab bar controller or navigation controller.

Best bet is to make sure the subview your addings dimensions are appropriate for the amount of space you have by creating a frame using CGRect.



来源:https://stackoverflow.com/questions/2277159/how-to-prevent-subview-from-overlapping-tab-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!