2016-02-18 11 views
6

Ho aggiunto swrevealcontroller nel mio app.On scatto di voce nella tabella apre una nuova vista controller.I hanno aggiunto un PageControl in quella vista controller.So primo gesto pan momento della PageControl opere, ma il prossimo il gesto pan temporale non funziona per il controllo della pagina. Per favore dimmi come posso evitare il conflitto del gesto pan.Conflitto di gesture di pagecontrollo con swrevealcontroller?

- (void)_handleRevealGesture:(UIPanGestureRecognizer *)recognizer 
{ 
    NSLog(@"handle pan gesture"); 
    CGPoint velocity = [recognizer velocityInView:self.view]; if(velocity.x > 0) 
    { 
     NSLog(@"gesture went right"); 
    } 
    else 
    { 
     NSLog(@"gesture went left"); 
     if(self.isReaveled) 
     { 
      switch (recognizer.state) 
      { 


       case UIGestureRecognizerStateBegan: 
        [self _handleRevealGestureStateBeganWithRecognizer:recognizer]; 
        break; 

       case UIGestureRecognizerStateChanged: 
        [self _handleRevealGestureStateChangedWithRecognizer:recognizer]; 
        break; 

       case UIGestureRecognizerStateEnded: 
        [self _handleRevealGestureStateEndedWithRecognizer:recognizer]; 
        break; 

       case UIGestureRecognizerStateCancelled: 
        //case UIGestureRecognizerStateFailed: 
        [self _handleRevealGestureStateCancelledWithRecognizer:recognizer]; 
        break; 

       default: 
        break; 
      } 

     } 
    } 


} 

Ho modificato il codice precedente per funzionare ma non funziona.

+0

in realtà ti è stato aggiunto lo swl in self.view corretto, il tuo gesto di scorrimento anche aggiunto a self.view, che il motivo è il conflitto –

+0

quindi qual è la soluzione allora? Come posso evitare il conflitto [email protected] – TechGuy

+0

di cui hai bisogno per lo più ... swl o swipe –

risposta

0

per prima cosa è stato impostato il delegato del comando pan di swrevealcontroller nel controller della vista in cui si utilizza il pagecontroller. per questo aggiungi anche il delegato di GesturerCogniser.

implementare questo metodo delegato di GestureRecongnizer.

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

    if (otherGestureRecognizer.delegate == self) 
     return NO; 

    if ([[otherGestureRecognizer.view class] isSubclassOfClass:[UIPageViewController class]]) { 
     NSLog(@"Allow1 %@", [otherGestureRecognizer description]); 
     return YES; 
    } 

    NSLog(@"Deny %@", [otherGestureRecognizer description]); 
    return NO; 
} 

Spero che ti possa aiutare.