我有一个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)添加长按手势 或者只是在标签栏中添加长按手势。
我该怎么办?
感谢。任何建议将不胜感激。
答案 0 :(得分:1)
只需输入您的UITabbarController方法
即可UITabBarController *tabBarController = [[UITabBarController alloc] init];
而不是用它来添加手势 - >
UILongPressGestureRecognizer *longRecog = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressed)];
[tabBarController.tabBar addGestureRecognizer:longRecog];
,选择器是 -
-(void)longPressed{
//Long pressed Occures
}