在整个视图中保留 UIToolbar 的按钮
在第一个导航控制器中,我向 UIToolbar 添加了四个按钮。这四个按钮也有四种不同的操作。
我的问题是,当我在导航堆栈中推送新的视图控制器时,UIToolbar 仍然可见,但四个按钮消失了。
如何保留按钮以及如何保留其操作,而无需重写代码以在我想要工具栏的每个视图中添加四个按钮和四个操作方法?
In the first navigation controller I've added four buttons to an UIToolbar. These four buttons have also four different actions.
My problem is when I push a new view controller in the navigation stack the UIToolbar is still visible but the four buttons disappears.
How to keep the buttons and how to keep their actions without rewriting the code to add four buttons and the four actions method in every view where I want the toolbar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建一个继承
UIToolbar
类(换句话说,您自己的自定义 Toolbar 类)的单独类,然后在屏幕上适当位置的后续类中创建并添加这个新类的对象的实例(它的底部)。或
创建一个继承
UIView
类的单独类,并向其添加按钮,使其具有与UIToolbar< 相同的外观和感觉/代码>。然后创建这个新类的对象的实例,并将该对象的
UIView
添加为子视图(使用[self.view addSubview:yourcustomViewObject.view];
)在适当的位置屏幕(其底部)。Make a separate class that inherits the
UIToolbar
class(in other words, your own custom Toolbar class) and then create and add instances of this new class' objects in subsequent classes at the proper location on the screen(its bottom).OR
Make a separate class that inherits the
UIView
class and add buttons to it that give the same look and feel as theUIToolbar
. Then make instances of this new class' objects and add this object'sUIView
as a subView (using[self.view addSubview:yourcustomViewObject.view];
) at the proper location on the screen(its bottom).