在UITabBar上方添加UIToolBar-逻辑问题 [英] Adding a UIToolBar above a UITabBar - Logic Issue
问题描述
我需要知道如何编写此代码的逻辑.
I need to know the logic of how to write this code.
这是我的问题.
当用户点击一个按钮时,我需要在视图上显示一个 UIToolBar
(上面有几个按钮).此 toolBar
应该仅出现在 UITabBarcontroller
上方.
When a user taps a button, I need to show a UIToolBar
(with a few buttons on it) on the view. This toolBar
should appear ONLY above the UITabBarcontroller
.
该视图是一个 UIScrollView
,因此,如果我对 UIToolBar
的位置进行硬编码,则每次用户滚动时该视图都会显示在错误的位置(希望您理解我在说什么).
The view is a UIScrollView
, so if I hardcode the position of the UIToolBar
, it will be displayed in the wrong position each time the user scrolls (Hope you understand what I am saying).
我做了以下事情.我对 UIToolBar
的位置进行了硬编码(因此它将放置在选项卡栏的上方),并将其添加到 Window
中.这听起来是个不错的解决方案,因为 windows
的大小在所有情况下都不会改变.
I did the following. I hard coded the position of the UIToolBar
(so it will place above the tab bar), and added it to the Window
. This sounds like a good solution as the windows
size will not change at all instance.
但是,我不想将此添加到 Window
.那还有什么其他方法可以解决这个问题吗?
But, I don't want to add this to a Window
. So is there any other way I could solve this problem?
推荐答案
我会在 window
上添加一个附加的 UIView
,以便它既充当 UIScrollView
和 UIToolbar
.然后调整滚动视图的大小,使其不超出工具栏.
I would add an additional UIView
to the window
so that it acts as a container for both the UIScrollView
and UIToolbar
. Then resize the scrollview so that it falls short of the toolbar.
您应该将其视为视图层
这篇关于在UITabBar上方添加UIToolBar-逻辑问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!