2011-10-18 8 views
-1

지도 키트 (처음 사용)가 필요한 앱을 개발 중이며 iphone에도 새로운 앱이 있습니다. 내 요구 사항은 사용자가 위치를 편집하고 핀을 사용하여 원하는 위치를 설정할 수 있다는 것입니다. 나는 많은 튜토리얼을 따르지만 사용자가지도에서 핀을 이동하기 위해 위치를 변경할 수 있다는 것을 알 수 없었다. 어떤 도움 plz, thnx.사용자가 mapkit iphone dev에서 위치를 어떻게 바꿀 수 있습니까?

+0

는 사용자가지도를 도청 곳에 핀이 저하 찾으셨습니까? – Manali

+0

예, NY의 북쪽 (일부 위치)에 설정된 사용자 마지막 위치와 같이 사용자가 동쪽 (일부 위치) NY을 클릭하면 NY의 동쪽으로 핀을 사용하여 위치가 변경됩니다. 가능합니까? 나를 도와 주려고 – Aleem

답변

1

UIGestureRecognizer를 사용하여 맵보기에서 터치를 감지 할 수 있습니다. 당신 설정 (예를 들어있는 viewDidLoad에서)지도보기,지도보기로 제스처 인식기를 부착 장소에서

:

UITapGestureRecognizer *tgr = [[UITapGestureRecognizer alloc] 
initWithTarget:self action:@selector(handleGesture:)]; 
tgr.numberOfTapsRequired = 2; 
tgr.numberOfTouchesRequired = 1; 
[mapView addGestureRecognizer:tgr]; 
[tgr release]; 

또는 길게 누르면 사용 :

UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] 
initWithTarget:self action:@selector(handleGesture:)]; 
lpgr.minimumPressDuration = 2.0; //user must press for 2 seconds 
[mapView addGestureRecognizer:lpgr]; 
[lpgr release]; 

을 방법 : 다음 handleGesture에서

- (void)handleGesture:(UIGestureRecognizer *)gestureRecognizer 
{ 
    if (gestureRecognizer.state != UIGestureRecognizerStateEnded) 
    return; 

    CGPoint touchPoint = [gestureRecognizer locationInView:mapView]; 
    CLLocationCoordinate2D touchMapCoordinate = 
    [mapView convertPoint:touchPoint toCoordinateFromView:mapView]; 

    MKPointAnnotation *pa = [[MKPointAnnotation alloc] init]; 
    pa.coordinate = touchMapCoordinate; 
    pa.title = @"Hello"; 
    [mapView addAnnotation:pa]; 
    [pa release]; 
} 
+0

tnx. – Aleem

관련 문제