如何将标签栏项目连接到操作? [英] How do you connect a tab bar item to an action?

查看:20
本文介绍了如何将标签栏项目连接到操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIView,它有一个 UITabBar,里面有 4 个 UITabBarItem 组件(都是从 IB 创建的).

I have a UIView which has a UITabBar with 4 UITabBarItem components in it (all created from IB).

我希望当有人点击标签栏中的项目时调用我的 IBAction 函数.但是我无法通过 IB 将 tabbaritem 连接到我的操作...我控制接收到的操作"中的拖动,但它不允许我将它连接到 tabbaritem.

I want my IBAction function called when someone clicks on the items in the tab bar. But I am unable to connect the tabbaritem to my action via IB... I control drag from the "received actions" but it does not allow me to connect that to the tabbaritem.

谢谢德肖恩

推荐答案

你的问题并不清楚你是否还定义了一个 UITabBarController.

It is not clear from your question if you also defined a UITabBarController.

如果你没有(我假设,否则如果你在 IB 中正确定义了东西,点击标签栏项目应该可以工作),要走的路是将 UITabBarDelegate 分配给你的 UITabBar 并定义 tabBar:didSelectItem:

If you did not (as I assume, otherwise clicking on a tab bar item should work if you correctly defined things in IB), the way to go is assigning a UITabBarDelegate to your UITabBar and define tabBar:didSelectItem:

看看 UITabBarDelegate 参考

这篇关于如何将标签栏项目连接到操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆