tengo un UIView
que contiene un UIScrollView
. Esta UIView
se supone que responde a algunos eventos táctiles, pero no responde debido al scrollView que contiene.
Este scrollView "s contentView
se establece en un MoviePlayer dentro de OuterView. Ahora, cada vez que hago clic en el área donde se encuentra el MoviePlayer, los eventos táctiles de mi OuterView no responden.
Incluso he puesto el reproductor de películas userInteraction
a NO
.
pero ahora scrollView está interfiriendo, parece.
Me he referido a este post en SO en sí.
Pero la solución allí, me pide que establezca la userInteractionEnabled
a NO
para el scrollView ¡Pero si lo hago, mi zoom de pellizco tampoco tiene lugar!
¿Qué hacer?
Respuestas
0 para la respuesta № 1Un UIScrollView intercepta todos los eventos táctiles porque tiene que decidir si / cuando el usuario ha movido su dedo para desplazarse por la vista de desplazamiento. Es posible que desee subclasificar UIView, luego en la
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)evt;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)evt;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)evt;
métodos, verifique los toques necesarios y luego reenvíe todos estos métodos a su UIScrollViewInstance. Por ejemplo:
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface MyView: UIView {
UIScrollView *scrollView;
}
@end
@implementation MyView
/* don"t forget to alloc init your ScrollView init -init
and release it in -dealloc! Then add it as a subview of self. */
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)evt
{
/* check for a gesture */
[scrollView touchesBegan:touches withEvent:evt];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)evt;
{
/* check for a gesture */
[scrollView touchesMoved:touches withEvent:evt];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)evt;
{
/* check for a gesture */
[scrollView touchesEnded:touches withEvent:evt];
}
@end