descubierto. En mi caso, mi UIScrollView contenía un UIImage que permití hacer zoom. Aparentemente, eso significaba que el desplazamiento estaba habilitado y UIScrollView tenía problemas para distinguir entre los gestos destinados a desplazarse frente a deslizar (siguiente, imagen anterior).
La clave en mi caso, es deshabilitar el desplazamiento en la vista de desplazamiento cuando la imagen no está ampliada, y cambiar el nombre cuando se acerca. Esto proporciona el comportamiento esperado.
La pieza fundamental es poner lo siguiente en el delegado de la vista de desplazamiento:
- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
if (scrollView.zoomScale!=1.0) {
// Zooming, enable scrolling
scrollView.scrollEnabled = TRUE;
} else {
// Not zoomed, disable scrolling so gestures get used instead
scrollView.scrollEnabled = FALSE;
}
}
También tengo que iniciar la vista de desplazamiento con desplazamiento deshabilitado. Para activar el zoom, sólo tiene que proporcionar una imagen en una llamada delegado,
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
// Return the scroll view
return myImage;
}
y establecer un par de parms en viewDidLoad de los reconocedores de zoom y configuración, así gesto
- (void)viewDidLoad {
[super viewDidLoad];
myScrollView.contentSize = CGSizeMake(myImage.frame.size.width, myImage.frame.size.height);
myScrollView.maximumZoomScale = 4.0;
myScrollView.minimumZoomScale = 1.0;
myScrollView.clipsToBounds = YES;
myScrollView.delegate = self;
[myScrollView addSubview:myImage];
[self setWantsFullScreenLayout:TRUE];
myScrollView.scrollEnabled = FALSE;
UISwipeGestureRecognizer *recognizer =
[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
recognizer.delaysTouchesBegan = TRUE;
[myScrollView addGestureRecognizer:recognizer];
[recognizer release];
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
recognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[myScrollView addGestureRecognizer:recognizer];
[recognizer release];
[myScrollView delaysContentTouches];
}
realmente excelente encontrar David. mis reconocedores de barrido tampoco funcionaron. Me rendí y utilicé touchesBegan: con NSNotification, pero también notificaba a MasterViewControllers (en el iPad). Tenía la vista borrosa de buscar ese problema. ¡Ahorraste mi tiempo n energía! sincero gracias David. Sigue publicando trucos ... ten un gran día. – gopikrishnan
Gracias por el truco – iOSAppDev
O tal vez en una línea - scrollView.scrollEnabled = (scale! = 1.0f) – Yariv