2010-07-15 12 views
5

¿Está bien anular -handlePan: en una subclase UIScrollView? es decir, ¿mi aplicación no será rechazada desde la tienda de aplicaciones?Reemplazar -handlePan: en UIScrollView

Gracias por compartir sus opiniones.

Edit: ¿qué hay de llamar a -handlePan: en otro método de mi subclase?

Respuesta

8

En caso de que alguien esté interesado, lo que hice en lugar de anular fue deshabilitar el UIPanGestureRecognizer por defecto y agregar otra instancia de UIPanGestureRecognizer que está mapeada a mi controlador personalizado.

Editar para twerdster:

lo hice como esto

//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

¿Cómo hiciste eso exactamente? – twerdster

+0

¿Cómo deshabilitó el valor predeterminado y cómo especificó el nuevo comportamiento para que se ajuste al comportamiento anterior y agregue su propio controlador? – twerdster

+1

@twerdster ver la publicación actualizada. – Altealice

4

Puede hacer que el código aún más corto.

//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 propiedad panGestureRecognizer solo se agrega en iOS 5. Hice el código anterior para iOS 3.2, así que esa era la única forma de hacerlo en ese momento. Buen consejo, sin embargo. – Altealice