我有我的应用程序中声明以下方法,并且我想实现一个开关打开和关闭我的mapView中的UILongPressGestureRecognizer
。UISwitch打开/关闭UILongPressGestureRecognizer
- (IBAction)addNewPin:(UISwitch *)sender {
if (sender.on) {
NSLog(@"ON!!");
}
else {
NSLog(@"OFF!!");
}
}
- (IBAction)didPressForPin:(UILongPressGestureRecognizer *)sender {
CGPoint point = [sender locationInView:self.mapView];
CLLocationCoordinate2D locCoord = [self.mapView convertPoint:point toCoordinateFromView:self.mapView];
MKPointAnnotation *pa = [[MKPointAnnotation alloc]init];
pa.coordinate = locCoord;
pa.title = @"Test Title!";
[mapView addAnnotation:pa];
NSLog(@"Pressed!!");
}
我知道我可以添加或删除gesturerecognizer或实施.enabled = NO
,但我不知道如何实现它的开关方法。
这个问题是如何与“的Xcode 4.5”? – 2012-10-12 19:44:21
你有99%,我不确定你不知道该怎么办? –