2010-07-15 15 views
5

È ok per sovrascrivere -handlePan: in una sottoclasse UIScrollView? la mia app non verrà rifiutata dall'app store?Overriding -handlePan: in UIScrollView

Grazie per aver condiviso le tue opinioni.

Modifica: che dire di chiamare -handlePan: in un altro metodo della mia sottoclasse?

risposta

8

Nel caso in cui qualcuno sia interessato, ciò che ho fatto invece di eseguire l'override è stato disabilitare l'UIPanGestureRecognizer e aggiungere un'altra istanza di UIPanGestureRecognizer che è mappata al mio gestore personalizzato.

Edit per twerdster:

ho fatto come questo

//disables the built-in pan gesture 
for (UIGestureRecognizer *gesture in scrollView.gestureRecognizers){ 
    if ([gesture isKindOfClass:[UIPanGestureRecognizer class]]){ 
    gesture.enabled = NO; 
    } 
} 

//add your own 
UIPanGestureRecognizer *myPan = [[UIPanGestureRecognizer alloc] init...]; 
//customize myPan here 
[scrollView addGestureRecognizer:myPan]; 
[myPan release]; 
+0

Come hai fatto esattamente? – twerdster

+0

Come hai disattivato l'impostazione predefinita e come hai specificato il nuovo comportamento in modo che si adattasse al vecchio comportamento e aggiungesse il tuo gestore? – twerdster

+1

@twerdster vedere il post aggiornato. – Altealice

4

È possibile rendere il codice ancora più breve.

//disables the built-in pan gesture 
scrollView.panGestureRecognizer.enabled = NO; 

//add your own 
UIPanGestureRecognizer *myPan = [[UIPanGestureRecognizer alloc] init...]; 
[scrollView addGestureRecognizer:myPan]; 
[myPan release]; 
+3

La proprietà panGestureRecognizer viene aggiunta solo in iOS 5. Ho creato il codice sopra per iOS 3.2, quindi era l'unico modo per farlo in quel momento. Bel suggerimento, comunque. – Altealice