2016-06-14 3 views
0

오랫동안 눌러 놓은 후에 그 위치 주변에서 오버레이를 꺼내려고합니다. 그러나 내가 긴 언론에서 설정 한 조치는 발사되지 않습니다. 여기 iOS 길게 누르기가지도상에서 작동하지 않습니다.

-(void) viewWillAppear:(BOOL)animated{ 
[super viewWillAppear:YES]; 

//add the long press options 

//single finger long press 
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(getMapCoordinateFromTouch:)]; 
[longPressGesture setNumberOfTouchesRequired:1]; 
longPressGesture.delegate = self; 
[self.mapview addGestureRecognizer:longPressGesture]; 

//double finger long press 
UILongPressGestureRecognizer *doubleLongPressGesture = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(removeBoundry:)]; 
[doubleLongPressGesture setNumberOfTouchesRequired:2]; 
doubleLongPressGesture.delegate = self; 
[self.mapview addGestureRecognizer:doubleLongPressGesture]; 

는 쿨

-(void)getMapCoordinateFromTouch:(UILongPressGestureRecognizer *) gesture{ 
if(gesture.state == UIGestureRecognizerStateBegan){ 
    CGPoint touchlocation = [gesture locationInView:self.mapview]; 
    pressedloc = [self.mapview convertPoint:touchlocation toCoordinateFromView:self.mapview]; 
    [self createBundarywithRadius:.1];  
} 
+0

1.보기에 중단 점을 넣으면 AppleAppear, self.mapView에 값이 있습니까? 2. 따라서 getMapCoordinateFromTouch의 중단 점이 실행되지 않습니다. – Dominic

+0

그것은 nill입니다. 지도보기를 초기화하려면 어떻게해야합니까? – pudm

답변

1

를 호출하는 기능입니다, 그래서 당신의지도보기 객체는 전무하다.

인터페이스 작성기를 사용하는 경우에는 시각 구성 요소에 속성을 연결하지 않은 것입니다. 이것은 기본적인 것들이며 이런 종류의 일을하는 방법에 대한 튜토리얼이 많이 있습니다.

@property (nonatomic, weak) IBOutlet MKMapView *mapview; 

이 인터페이스 빌더 구성 요소에 매여되지 않고 그 문제입니다 : 요컨대

, 당신은 이미 뭔가를해야한다!

해피 코딩 ...