我想向 a 添加一个披露按钮以MKAnnotation
转到另一个视图。
该按钮应如下所示:
这是我的.h和.m文件。
.h 文件
//
// POI.h
//
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface POI : NSObject <MKAnnotation> {
NSString *title;
NSString *subtitle;
CLLocationCoordinate2D coordinate;
}
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
- (id)initWithCoordinate:(CLLocationCoordinate2D)_coordinate title:(NSString *)_titolo andSubTitle:(NSString *)_sottotitolo;
@end
.m 文件
//
// POI.m
#import "POI.h"
@implementation POI
@synthesize title, subtitle, coordinate;
-(id)initWithCoordinate:(CLLocationCoordinate2D)_coordinate title:(NSString *)_titolo andSubTitle:(NSString *)_sottotitolo {
[self setTitle:_titolo];
[self setSubtitle:_sottotitolo];
[self setCoordinate:_coordinate];
return self;
}
@end
在我的 ViewController 中,我使用以下方法调用它:
pinLocation.latitude = 4.8874;
pinLocation.longitude = 1.400;
POI *poi = [[POI alloc] initWithCoordinate:pinLocation title:@"foo" andSubTitle:@"bar"];
[_mapView addAnnotation:poi];