私はのViewControllerのナビゲーションコントローラを持っているので、私はので、このdoesntのは、ビュー上でスワイプを無効にするには、このスワイプジェスチャー認識プログラムは方向を検出できません。
UISwipeGestureRecognizer *noRightShiftForVolume = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleVolumeViewSwipe1:)];
[self.circleProgressBar addGestureRecognizer:noRightShiftForVolume];
のようなジェスチャー認識装置を使用していた場合。 しかし、このように宣言するとうまくいくが、スワイプの方向はわからない。
UIPanGestureRecognizer *noRightShiftForVolume = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleVolumeViewSwipe1:)];
[self.circleProgressBar addGestureRecognizer:noRightShiftForVolume];
関数のimplemenationは次のようである:ナビゲーションコントローラ BOOL eliminateSwipeで
- (void)handleVolumeViewSwipe1:(UISwipeGestureRecognizer *)sender
{
if (sender.state == UIGestureRecognizerStateBegan) {
[applicationControllerShared() enableSwipe:NO];
NSLog(@"good karens");
if(UISwipeGestureRecognizerDirectionLeft){
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setDuration:0.50];
[animation setTimingFunction:
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[_circleProgressBar.layer addAnimation:animation forKey:kCATransition];
NSLog(@"Swipe Left");
}
if(UISwipeGestureRecognizerDirectionRight){
NSLog(@"Swipe Right");
}
}
if (sender.state == UIGestureRecognizerStateEnded)
{
[applicationControllerShared() enableSwipe:YES];
NSLog(@"good karens 110");
}
}
。このような eliminateSwipe機能ルック:
-(void) enableSwipe: (BOOL) state
{
eliminateSwipe = !state;
}
がスワイプ機能を有効にするには、ナビゲーションコントローラのスワイプを無効にし、私の機能handleVolumeViewSwipe1を実現するために力を与えます。 私は左右のスワイプを検出して機能を実行したい円の進捗バーを持っています。どのように私はそれを行うことができますどのような手掛かり。
私はこのSwipeGestureRecognizerDirectionをViewDidLoadとViewDidAppearで実装しようとしましたが、ナビゲーションコントローラのスワイプ機能のために働いていません。
これはUIPanGestureRecognizerの助けを借りて解決され、あなたがpopGestureを停止するUINavigationControllerDelegate
のデリゲートを適用する必要があり、私のexprienceを1としてスワイプは、次のコード
if (sender.state == UIGestureRecognizerStateBegan) {
[applicationControllerShared() enableSwipe:NO];
CGPoint velocity = [sender velocityInView:_circleProgressBar];
if(velocity.x < 0)
{
NSLOG(@"swipe left");
}else{
NSLOG(@"swipe right");}
}
ジェスチャーの 'noRightShiftForVolume.direction'プロパティを設定しましたか? – CodeChanger
はい、それはまったく役に立ちません。スワイプは、ナビゲーションコントローラ –
に私を連れて行くので、それはそのviewController右から飛び出すでしょうか? – CodeChanger