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

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

问题描述

我有一个UIView,它有一个UITabBar,其中有4个UITabBarItem组件(都是从IB创建的)。



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



感谢
Deshawn

解决方案

如果您也定义了一个UITabBarController, p>

如果你没有(如我想象的,否则点击一个标签栏项目应该工作,如果你正确地定义在IB中的东西),方法是分配一个UITabBarDelegate到你的UITabBar并定义 tabBar:didSelectItem:



请查看 UITabBarDelegate 参考


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

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.

Thanks Deshawn

解决方案

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

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:

Have a look at the reference for UITabBarDelegate

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

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