MKMapView - より多くの結果をロード中に呼び出されていないviewForAnnotation
-
21-09-2019 - |
質問
編集追加する*私は、まだ缶誰も助けてくださいをこの1のための解決策を見つけることができますか?ピン後 MKMapViewリフレッシュ - 私の問題は、これに似ていますが、答えは私のために仕事をtはありません投稿しました*エンド編集
の移動私は、検索マップビューを有効にしています。ユーザーが検索にヒットすると、私のカスタム注釈は、マップビューに追加されます。検索は「負荷より」リンクと20件の結果を返します。私はより多くの負荷を打つときに、より多くの注釈は、ビューをマップに追加する必要があります。
問題がある - 注釈は、マップビューに追加されますが、マップ上に表示されません。 Iは、ズームインまたはマップ領域を変更するためにズームアウトした場合、ピンが示されています。
私はそのviewForAnnotationsを見つける:i「はより多くの負荷を」ヒットしたときに呼び出さ取得されていません。私はこれをトリガーするかどうかはわかりません。いずれか?
-(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
これは、時間の経過通知を受けた後、注釈ピンを追加することとは何かを持っていました。働いていた注釈ピンを追加するためにメインスレッドを使用するように強制。
他のヒント
単に確認するために望んでいました doesntの仕事 - 私は、スレッドから注釈を加えるました。 私が使用したら、これは(addCameraIconOnMainは私annoationsを追加します)。
[self performSelectorOnMainThread:@selector(addCameraIconOnMain:) withObject:cd waitUntilDone:true];
その働きました!ありがとう!
私の場合の問題は、私は、マップデリゲートの前に注釈を追加しました。
:それはのようなものでなければなりません- (void)viewDidLoad
{
...
// map delegate
[mView setDelegate:self];
...
// add annotation
[_map addAnnotation:_poiAnnotation];
...
}
所属していません StackOverflow