如何在UIScrollView中将UIToolbar固定到屏幕底部 [英] How can I pin a UIToolbar to the bottom of the screen in a UIScrollView

查看:173
本文介绍了如何在UIScrollView中将UIToolbar固定到屏幕底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含UIToolbar的UIScrollView,但是当我滚动时,工具栏也会滚动,与屏幕底部分开。当滚动发生时,是否有办法让工具栏粘在屏幕底部?

I have a UIScrollView that contains a UIToolbar, but when I scroll, the toolbar scrolls as well, separating from the bottom of the screen. Is there a way to make the toolbar stick to the bottom of the screen as the scroll happens?

我试图创建一个包含ScrollView和工具栏的视图,但是当程序运行时,ScrollView就是我所能看到的。这个问题可能是由于ScrollView被绘制在工具栏的顶部,但我不确定。

I tried to create a view that contained both the ScrollView and the Toolbar, but when the program runs, the ScrollView is all that I can see. This problem could be due to the ScrollView being drawn on top of the toolbar, but I'm not sure.

这两种方法中的任何一种都有帮助(甚至是第三,我还没有想到)将非常感谢。

Any help in either of these two methods (or even a third that I haven't thought of yet) would be greatly appreciated.

谢谢,

Chris

Thanks,
Chris

推荐答案

如果您正在使用界面构建器,则只需重新调整UIScrollView的大小,使其位于UIToolbar所在的位置。 (首先放置UIToolbar,UIScrollView很可能会捕捉使用可用空间。)

If you're using the interface builder, you can simply re-size the UIScrollView so that it sits above where the UIToolbar will be placed. (Place the UIToolbar first and the UIScrollView will most likely snap to use the available space.)

如果您以编程方式添加UIToolbar,则可以允许其存在在属性检查器的模拟指标部分的底栏下选择工具栏选项。

If you're adding the UIToolbar programmatically, you can allow for its presence by selecting the "Toolbar" option under "Bottom Bar" within the Simulated Metrics section of the attributes inspector.

这篇关于如何在UIScrollView中将UIToolbar固定到屏幕底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆