我在iPhone MapView中尝试过以下代码
UITapGestureRecognizer * Tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(checktap)]; [self.mapView addGestureRecognizer:Tap]; [点击发布];
UIPinchGestureRecognizer * pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(checkpinch)]; [self.mapView addGestureRecognizer:pinch]; [捏释];
水龙头工作但夹点检测不起作用。
请帮帮我。
感谢高级。
答案 0 :(得分:3)
在您的视图中添加以下代码,并在您的.h文件中添加Gesture识别器代理。
...享受:)
[self.view insertSubview:mapView atIndex:0];
//Gesture reconizer
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(checkpinch)];
[pinch setDelegate:self];
[pinch setDelaysTouchesBegan:YES];
[self.mapView addGestureRecognizer:pinch];
[pinch release];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(checktap)];
[singleTap setDelegate:self];
singleTap.numberOfTapsRequired = 1;
singleTap.numberOfTouchesRequired =2;
[self.mapView addGestureRecognizer:singleTap];
[singleTap release];
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(checktap)];
[doubleTap setDelegate:self];
doubleTap.numberOfTapsRequired = 2;
doubleTap.numberOfTouchesRequired =1;
[self.mapView addGestureRecognizer:doubleTap];
[doubleTap release];