我试图在导航栏上添加平移手势识别器:
[self.navigationController.navigationBar addGestureRecognizer:self.panGestureRecognizer];
但它似乎没有触发手势。有什么想法吗?
答案 0 :(得分:2)
首先创建pangesture对象。 将手势识别器添加到导航栏视图。
然后调用您的手势识别器方法。
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(pushVC:)];
[self.nav.view addGestureRecognizer:panGesture];
-(void)pushVC:(UIPanGestureRecognizer *)gesture
{
if(gesture.state == UIGestureRecognizerStateEnded)
{
pushVC *pushvc = [[pushVC alloc] initWithNibName:@"pushVC" bundle:nil];
[self.nav pushViewController:pushvc animated:YES];
}
}