本文介绍了如何为UITabBarItem创建动作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个没有UITabBarController的UITabBar和UITabBarItems,现在我想知道如何在单击UITabBarItem时进行操作.对UITabBarItem进行操作应该使用什么方法?
I have created a UITabBar and UITabBarItems without UITabBarController on it, now i want to know how to place an action on click of the UITabBarItem.What is the method i should use for action on UITabBarItem?
推荐答案
您不能直接在UITabBarItem
对象上设置操作.相反,您的视图控制器应实现以下UITabBarDelegate
方法:
You can't set an action on a UITabBarItem
object directly. Instead, your view controller should implement the following UITabBarDelegate
method:
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item;
当用户选择一个选项卡(即UITabBarItem
)时,将调用此方法.
This method is called when the user selects a tab (i.e. UITabBarItem
).
这篇关于如何为UITabBarItem创建动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!