如何以编程方式确定 iOS 中按下了哪个选项卡按钮?
我有一个标签栏,上面有 4 个按钮。当用户按下 A 按钮时我想调用 functionA。当用户按下 B 按钮时我想调用 functionB 等等。
我已经实现了 UITabBarDelegate。
我有这段代码,当按下选项卡栏上的任何按钮时,它会按预期触发。
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
我正在寻找的是一个代码片段,说明如何检测可能使用 item 的委托内部按下了哪个按钮。
I have a tabbar with 4 buttons on it. When the user presses the A button I want to call functionA. When the user presses the B button I want to call functionB and so on.
I have implemented the UITabBarDelegate.
I have this code and it fires as expected when any button on the tabbar is pressed.
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
What I am looking for is a code snippet that illustrates how to detect which button was pressed inside the delegate presumably using item.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢下面 iwat 的评论,我将其编辑得更简单。
以下是 UITabBarController 的委托调用,而不是 UITabBar 本身。
Thanks to iwat's comment below I edited this to be simpler.
The following is a delegate call for the UITabBarController, rather than the UITabBar itself.