そのため、アプリケーションの画面上のサブビューの 1 つにスワイプ ジェスチャを追加しようとしています。ジェスチャ認識エンジンを次のように宣言します。
UISwipeGestureRecognizer *swiperR = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(switchStackingMode:)];
[swiperR setDirection:UISwipeGestureRecognizerDirectionRight];
[chart addGestureRecognizer:swiperR];
UISwipeGestureRecognizer *swiperL = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(switchStackingMode:)];
[swiperL setDirection:UISwipeGestureRecognizerDirectionLeft];
[chart addGestureRecognizer:swiperL];
-(void)switchStackingMode:(UISwipeGestureRecognizer *)sender {
NSLog(@"inside switchstack from gesture");
//other stuff
}
アプリケーションの起動時にサブビューを操作しようとすると、スワイプ ジェスチャ swiperL のみが機能します。右スワイプしても反応なし。私は最初、方向を指定して 1 つのジェスチャ認識エンジン (UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight) を実行しようとしましたが、それは機能せず、他のスタック オーバーフローの回答に基づいて、2 つの別個の認識エンジンに戻しました。まだ運がなく、これには困惑しています。私は何かが欠けているように感じます..