2013-03-06 86 views
1

我已添加tableview作爲subview並且我已將​​添加到tableview。刷卡不起作用。 Pan gesture工作正常(剛測試)。 Swipe gesture它不起作用。我想把桌子移到右邊。所以我想只在向右滑動時纔會觸發動畫。但輕掃本身並不被認可。刷卡表格

panelGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(closePanel:)]; 
    [panelGesture setDirection: UISwipeGestureRecognizerDirectionRight]; 

    [panel addGestureRecognizer:panGesture]; 

回答

1

當你使用一個以上的手勢識別,那麼你需要實現以下手勢識別的委託方法,使他們分別工作都

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer 

你需要返回YES

+0

讓我試試並找回你。謝謝 – Manoj 2013-03-06 10:00:06

+0

太棒了。這是我正在尋找的。涼。非常感謝。你節省了我的時間。 – Manoj 2013-03-06 10:03:37

1

五月是它幫助你,但我不知道,嘗試像這樣它會工作在我的情況下它工作正常

UISwipeGestureRecognizer *swiper = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(closePanel)] autorelease]; 
    swiper.delegate=self; 
    [swiper setDirection:UISwipeGestureRecognizerDirectionRight]; 
    [tableview addGestureRecognizer:swiper]; 

而在.h文件中

+0

對不起,我忘記了提及。我也給了代表。仍然不工作 – Manoj 2013-03-06 09:59:47

+0

在我的情況下,它工作正常。 – Balu 2013-03-06 10:00:36

2

使用下面的代碼給委託<UIGestureRecognizerDelegate> ...

在.m文件

UISwipeGestureRecognizer *leftToRightSwipGesture; 

在要.m文件.h文件中或私人範圍添加手勢識別也把這個代碼...

leftToRightSwipGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(sampleGesture)]; 
    [leftToRightSwipGesture setDirection:UISwipeGestureRecognizerDirectionRight]; 
    [dashboardInventoryTableView addGestureRecognizer:leftToRightSwipGesture]; 

在.m文件樣本方法手勢

-(void)sampleGesture 
{ 
    NSLog(@"Gesture Recognized"); 
} 
+0

謝謝你的時間來幫助我。 – Manoj 2013-03-06 10:16:17

+0

這就是我真正在做的。但刷卡根本不會觸發。我接受了默特的回答,那就是我真正想要的。 – Manoj 2013-03-06 10:23:51