用于获取地址的 MKA 注释



我注意到新的地图应用程序具有我需要在我正在制作的应用程序中实现的功能。该功能是当用户将图钉放在某个位置上时,地址将显示为注释视图的副标题。有谁知道该怎么做?

您应该在自定义注释中实现字幕属性,例如:

// Geo.h
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
@interface Geo : NSObject <MKAnnotation>
@property (nonatomic, strong) NSString* subtitle;
// Geo.m
#include "Geo.h"
@implementation Geo
- (NSString *)subtitle
{
    return _subtitle; // Here you can reverse geocoding to get address from a CLLocationCoordinate2D object
};

最新更新