如何更改 UITabBarItem 操作?
我的 iOS 应用程序的主窗口包含一个 UITabBarController。有 3 个 UITabBarItem,每个都显示不同的视图。
我认为选项卡栏是直接使用 xcode 选项卡栏应用程序模板创建的。现在我创建了另一个视图,我想用新视图替换现有视图,但我没有看到任何将视图分配给 UITabBarItem 按钮的代码。我该怎么做?
The main window of my iOS application contains a UITabBarController. There're 3 UITabBarItem and they show a different view each.
I think the tab bar was directly created with the xcode tab bar application template. Now I created another view and I want to replace the existing one with the new one but I don't see any code that assign a view to the UITabBarItem button. How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想在代码中执行此操作,请查看此 UITabBarController 方法
setViewControllers:animated:
示例代码
如果您使用 IB,则将所需的 UIViewController 分配给您的选项卡。
If you want to perform this action in code then look at this UITabBarController method
setViewControllers:animated:
Sample code
If you using IB, then assign required UIViewController to your tab.
您可以将自定义选项卡放置在 UITabBarController 视图上的正确位置,但是您需要自己处理所有选项卡切换,这并不太难。
You could place your custom tabs over the view of your UITabBarController at the right position, but them you need to handle all the Tab switching by yourself, which is not too hard.