2 AppDelegate中的手指向上滑动操作

时间:2014-03-17 07:39:18

标签: ios uigesturerecognizer appdelegate

当用户用两根手指向上滑动时,我想更改导航栏色调颜色。我需要在App Delegate中执行此操作,以便我可以普遍更改所有导航栏色调颜色。我可以做一个手势,但我不确定如何实际调用一个动作。谢谢你的帮助:D

1 个答案:

答案 0 :(得分:1)

您是否尝试过写作:

[self.navController.view addGestureRecognizer:yourGestureInstanceHere];

此处yourGestureInstanceHere表示点击次数为2的滑动手势。

另外,我建议子类你的UINavigationController并在那里写这个功能,而不是AppDelegate。 AppDelegate不是处理这些功能的类。

修改

-(void)addGestureToNavigationController

    UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeRight:)];

    [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];

     swipeRight.numberOfTouchesRequired = 2;

    [swipeRight setDelegate:self];

    [self.navigationController.view addGestureRecognizer:swipeRight];

}

// Selector

-(void)handleSwipeRight:(UISwipeGestureRecognizer *)recognizer

{

    // TODO : Write change tint colour logic

}