如何防止子视图重叠的标签栏?

问题描述:

我有一个视图,底部有标签栏。此视图是在导航控制器上推送的,因此在顶部还有一个导航栏。在这个视图中,我想显示一个表视图,它是从自己的笔尖创建的。当我将此视图添加为子视图时,它与选项卡栏重叠。

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

在界面生成器中,确保您已设置导航栏和标签栏间隔。它应该是接口构建器属性视图中第一个选项卡上的第一个选项列表。这将使您的视图模拟视图中加载时的空间量。

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.

最好的办法是确保子视图的添加尺寸适合您通过创建框架的空间量使用CGRect。

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.