的MKMapView - viewForAnnotation同时加载多个结果不叫
-
21-09-2019 - |
题
编辑补充*我还没有找到这一个解决方案呢,谁能请帮助?我的问题是与此类似,但张贴的答案确实不是T为我工作 - 针后的MKMapView刷新移动 *结束修改
我有一个搜索启用地图视图。当用户点击搜索,我的自定义注释添加到地图视图。搜索返回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
解决方案 2
此不得不是与时间经过接收到该通知,然后添加注解引脚。迫使它使用的主线程添加注释工作引脚。
其他提示
只想确认 我加入了从一个线程的注解 - 它不工作。 一旦我用这个(addCameraIconOnMain增加我annoations)
[self performSelectorOnMainThread:@selector(addCameraIconOnMain:) withObject:cd waitUntilDone:true];
它的工作!谢谢!
在我的情况下,问题是我被添加在地图代表之前的注释。它必须是这样的:
- (void)viewDidLoad
{
...
// map delegate
[mView setDelegate:self];
...
// add annotation
[_map addAnnotation:_poiAnnotation];
...
}
不隶属于 StackOverflow