0
私が働いている問題がある:私はMKMapKitを持ってタップし、名前を返す
と、ユーザが建物をタップするたびに、通り、名前はそうのように、のMapViewからポップアップ表示されます:
私はそうのように、自分自身のクラスAddressAnnotationを持っている:
AddressAnnotation.h
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface AddressAnnotation : NSObject <MKAnnotation>
- (id)initWithName:(NSString *)name address:(NSString *)address coordinate:(CLLocationCoordinate2D)coordinate;
@end
AddressAnnotation.m
#import "AddressAnnotation.h"
#import <AddressBook/AddressBook.h>
@interface AddressAnnotation()
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *address;
@property (nonatomic, assign) CLLocationCoordinate2D theCoordinate;
@end
@implementation AddressAnnotation
- (id)initWithName:(NSString*)name address:(NSString*)address coordinate:(CLLocationCoordinate2D)coordinate {
if ((self = [super init])) {
if ([name isKindOfClass:[NSString class]]) {
self.name = name;
} else {
self.name = @"";
}
self.address = address;
self.theCoordinate = coordinate;
}
return self;
}
- (NSString *)title {
return _name;
}
- (NSString *)subtitle {
return _address;
}
- (CLLocationCoordinate2D)coordinate {
return _theCoordinate;
}
そして、私のメインのMapViewControllerで、私はポイントを指定し、その場所にピンを追加し、それは私が欲しいものではありませんすることができます。私はちょうどオブジェクトをタップし、その名前をポップアップさせたいと思っています。
このような質問は見つかりませんでした。質問が重複している場合はお知らせください。
ありがとうございます。