因此,我正試圖在我的應用程序的屏幕上爲其中一個子視圖添加滑動手勢。我宣佈手勢識別如下:UISwipeGestureRecognizer不按預期方式工作
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工作。我沒有迴應正確的刷卡。我最初嘗試使用方向(UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight)只做一個手勢識別器,但沒有奏效,並且基於其他堆棧溢出答案,我還原爲兩個單獨的識別器。仍然沒有運氣,這讓我感到困惑。我覺得我失去了一些東西..
你的代碼似乎很好,它正在檢測左右滑動。 – Leena 2012-07-19 13:33:55
上述確定對我來說很好。 – Bourne 2012-07-19 13:34:26
當我在圖表子視圖上向左滑動時,NSLog會打印。當我向右滑動時,沒有任何反應。 – ascendancy05 2012-07-19 13:34:48