例如:我有UIView
并且我检测到长按 - 然后出现新的UIView
。它现在需要整个屏幕。我仍然在屏幕上放下手指 - 我可以移动手指,但我无法向上移动,因为我的新UIView
将会消失。所以现在我必须检测我的新UIView
上的触摸,但是没有触及开关和touchesMoved
被调用。有没有办法解决这个问题?
我新UIView
的代码:
#import "Menu.h"
@implementation Menu
{
// int x;
// int y;
UIGestureRecognizer *longPressGesture;
}
- (id)initWithFrame:(CGRect)frame
{
NSLog(@"initWithFrame");
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor orangeColor];
self.userInteractionEnabled = YES;
[self setMultipleTouchEnabled:YES];
[self setIsAccessibilityElement:YES];
longPressGesture = [[UIGestureRecognizer alloc]
initWithTarget:self
action:@selector(longPressBegan:)];
[self addGestureRecognizer:longPressGesture];
}
return self;
}
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"TOUCHES BEGAN");
}
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"TOUCHES MOVED");
}
-(void)longPressBegan:(UIGestureRecognizer *)recognizer
{
NSLog(@"LONG PRESS");
}
这些方法(touchesBegan,touchesMoved,longPressBegan)都没有被调用。