如何防止子视图与标签栏重叠?
我有一个底部带有标签栏的视图。该视图被推送到导航控制器上,因此顶部也有一个导航栏。对于这个视图,我想显示一个表视图,它是我从它自己的笔尖创建的。当我将此视图添加为子视图时,它与选项卡栏重叠。
有没有办法让这个子视图自动调整大小到顶部栏和底部栏之间的可用空间?
如果不是,调整其尺寸以适应的“正确”方法是什么?
-维加
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在界面生成器中,确保您已设置导航栏和选项卡栏间隔。它应该是界面构建器属性视图中第一个选项卡上的第一个选项列表。这将使您的视图模仿加载到视图中时所具有的空间量。
从那里您还可以选择剪辑子视图的选项。界面生成器还允许您设置视图的调整大小选项。如果您添加的子视图不是在界面生成器中创建的,您将必须手动指定这些选项。
最后确保将子视图附加到正确的视图,而不是选项卡栏控制器或导航控制器。
最好的办法是通过使用 CGRect 创建框架来确保您添加的子视图尺寸适合您拥有的空间量。
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.