0
我注意到,新的地圖應用程序有一個功能,我需要在我正在製作的應用程序中實現。該功能是當用戶在某個位置放置一個PIN時,該地址將顯示爲註釋視圖的副標題。有誰知道這是怎麼做到的嗎?MKAnnotation獲取地址
我注意到,新的地圖應用程序有一個功能,我需要在我正在製作的應用程序中實現。該功能是當用戶在某個位置放置一個PIN時,該地址將顯示爲註釋視圖的副標題。有誰知道這是怎麼做到的嗎?MKAnnotation獲取地址
你應該在你的自定義註釋實現字幕屬性,如:
// 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
};