ios - 如何将自定义手势添加到 UITabBarController 中的选项卡

标签 ios uitabbarcontroller gesture

我有一个 tabbarController:

UITabBarController* tabBarController = [[UITabBarController alloc] init];
UIViewController* view1 = [[UIViewController alloc] init];
UIViewController* view2 = [[UIViewController alloc] init];
tabBarController.viewControllers = [NSArray arrayWithObjects:view1, view2, nil];

我想添加一个长按手势到 view1 的标签按钮(称为 tabBarItem) 或者只是向标签栏添加长按手势。

我该怎么办?

谢谢。任何建议将不胜感激。

最佳答案

只需放置您的 UITabbarController 方法

UITabBarController *tabBarController = [[UITabBarController alloc] init];

然后用它来添加手势->

UILongPressGestureRecognizer *longRecog = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressed)];

[tabBarController.tabBar addGestureRecognizer:longRecog];

选择器是 -

-(void)longPressed{
    //Long pressed Occures

}

关于ios - 如何将自定义手势添加到 UITabBarController 中的选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30888498/

相关文章:

ios - 在屏幕不在标签栏上的情况下启动 uitabviewcontroller

ios - 如何更改 TabBar 项目导航标题

angularjs - 如何在 ionic 谷歌地图中长按/按住时获取坐标值

eclipse - 是否可以在 Eclipse 中禁用双指缩放?

ios - 如何生成设备库标识符?

ios - iOS文字游戏框架

ios - 我可以为自己在 Objective-C 中的弃用添加修复吗?

ios - 图标图像未显示在iOS 7的标签栏中?

ios - 过滤选项卡栏 Controller 中的选项卡?

java - Canvas.drawLines 显示不连续的线段