How can I pin a UIToolbar to the bottom of the screen in a UIScrollView

和自甴很熟 提交于 2020-01-16 03:23:06

问题


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?

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.

Thanks,
Chris


回答1:


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.)

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.



来源:https://stackoverflow.com/questions/5760467/how-can-i-pin-a-uitoolbar-to-the-bottom-of-the-screen-in-a-uiscrollview

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