为什么我无法将引脚地址设置为注释的副标题?

时间:2012-06-05 12:34:35

标签: ios xcode annotations street-address subtitle

如果== nil,尝试将引脚位置的地址设置为注释副标题。但没有任何反应。

if (myAnnotation.subtitle == nil)
                    [self.geoCoder reverseGeocodeLocation: locationManager.location completionHandler: 
                     ^(NSArray *placemarks, NSError *error) {

                         CLPlacemark *placemark = [placemarks objectAtIndex:0];
                         NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];  
                         myAnnotation.subtitle = locatedAt;

                     }];   
                else {
                    myAnnotation.subtitle = [[ann objectAtIndex:i] objectForKey:@"Address"];
                }

1 个答案:

答案 0 :(得分:0)

您的代码正在发生的事情是地理编码器是一个异步操作。您的引脚在地理编码完成之前放置。根据代码的设置方式,您可能会在地理编码完成之前丢失对引脚的引用。在创建注释之前,请尝试对地标进行地理编码。