编辑添加 *我还没有找到解决这个问题的方法,有人可以帮忙吗?我的问题与此类似,但发布的答案对我不起作用 - MKMapView refresh after pin move *End Edit
我有一个启用搜索的地图视图。当用户点击搜索时,我的自定义注释会添加到地图视图中。搜索返回 20 个带有“加载更多”链接的结果。当我点击加载更多时,应该向地图视图添加更多注释。
问题是 - 注释被添加到地图视图中,但未显示在地图上。如果我放大或缩小以更改地图区域,则会显示图钉。
我发现当我点击“加载更多”时 viewForAnnotations: 没有被调用。我不确定如何触发它。任何人?
-(void)completedSearch:(NSNotification *)resultNotification
{
//begin loop
//get coordinate
customAnnotation *annot = [[customAnnotation alloc] initWithCoordinate:coordinate];
//set title subtitle
[annotationsArray addObject:annot];
//end loop
[mView addAnnotations:annotationsArray];
[mView setRegion:region animated:YES];
[mView regionThatFits:region];
}
//custom annotation
@interface customAnnotation : NSObject <MKAnnotation>
{
CLLocationCoordinate2D coordinate;
NSString* title;
NSString* info;
}
@property (nonatomic, retain) NSSting *title;
@property (nonatomic, retain) NSSting *info;
-(id) initWithCoordinate:(CLLocationCoordinate2D)c;
@end
@implementation customAnnotation
@synthesize coordinate, title, info;
-(id) initWithCoordinate:(CLLocationCoordinate2D)c
{
coordinate = c;
return self;
}
-(void)dealloc{//dealloc stuff here}
@end