将 UITabBar 中的选项卡栏按钮替换为 UIButton
我在选项卡栏中有一个应用程序,但我需要放置一个 UIButton 来代替选项卡栏按钮。里面有4个tabbarbutton,我想用UIButton替换那个。谢谢。
I have an application in tabbar, but I need to put a UIButton insted of a tabbar button. There are 4 tabbarbuttons in it, I want to replace the one with UIButton. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想使用 UIButtton 而不是选项卡栏,请使用所有四个选项卡。将一个选项卡留空,并在要替换的同一视图中放置一个相同大小的按钮。
If you want to use UIButtton instead of tabbar, use all four tabs. Make one tab blank and put a button of same size at same view on which you want to replace.
假设您的意思是 toolBar 而不是 tabBar (否则这个问题没有意义;见下文),只需将项目保存在 NSMutableArray 中,并将索引 i 处的对象替换为您想要替换的任何对象,然后将新数组设置为 toolBar再次项目。
您可以通过阅读 UIToolbar 文档。简而言之,我的建议大致如下:
为什么在选项卡栏中放置按钮没有意义?
嗯,有几个原因。你不能的或许就是最好的。另一个好处是,您想要对潜在按钮执行的任何操作都可以放入在选择选项卡栏时出现的 viewController 的 viewWillAppear 方法中。
Assuming you mean toolBar instead of tabBar (otherwise this question makes no sense; see below), just save the items in an NSMutableArray and replace the object at index i with whatever you wish to replace it with, then set the new array as the toolBar items once again.
You can figure out all the details of doing this by reading the UIToolbar Documentation. In short, I'm suggesting something along the lines of this:
Why does it make no sense to put a button in a tabbar?
Well, a few reasons. You can't is probably the best. Another good one is that any action you want for the would-be button can be put instead into the
viewWillAppear
method of the viewController that appears when that tabbar selection is made.