2017-04-20 9 views
1

저는 Apple의지도로 두 곳의 경로를 표시하려고합니다.MKPlacemark의 표시 이름을 설정하는 방법은 무엇입니까?

두 곳은 이름과 좌표가 있습니다.

MKMapItem *currentLocation = [[MKMapItem alloc] 
    initWithPlacemark:[[MKPlacemark alloc] 
         initWithCoordinate:paramModel.fromCoordinate2D 
        addressDictionary:nil]]; 
MKMapItem *toLocation = [[MKMapItem alloc] 
    initWithPlacemark:[[MKPlacemark alloc] 
         initWithCoordinate:paramModel.toCoordinate2D 
         addressDictionary:nil]]; 
return [MKMapItem openMapsWithItems:@[ currentLocation, toLocation ] 
        launchOptions:@{ 
         MKLaunchOptionsDirectionsModeKey : 
          MKLaunchOptionsDirectionsModeDriving 
        }]; 

이 이름은 paramModel 안에 저장됩니다.

나는 이것을 addressDictionary을 사용하여 얻을 수 있다고 가정합니까? kABPersonAddressStreetKeykABPersonAddressCityKey을 시도했지만 어느 것도 최종 경로보기에 표시되지 않습니다.

답변

0

변수로 MKPlacemark을 만들고 다음과 같이 해당 변수에 제목 필드를 수정하십시오 :

MKPlacemark* placemark = [[MKPlacemark alloc] 
        initWithCoordinate:paramModel.fromCoordinate2D 
       addressDictionary:nil]]; 
placemark.title = @"Some Title"; 
placemark.subtitle = @"Some subtitle"; 

그런 다음지도 항목 생성자의 매개 변수로 변수를 설정하십시오.

+0

미안하지만 'title'과'subtitle' 필드는'readonly'입니까? –

0

name 필드를 MKMapItem으로 직접 수정할 수 있습니다.

MKMapItem *currentLocation = [[MKMapItem alloc] 
    initWithPlacemark:[[MKPlacemark alloc] 
        initWithCoordinate:paramModel.fromCoordinate2D 
       addressDictionary:nil]]; 
currentLocation.name = paramModel.fromName;