マップビューをロードしています。そして私はアドレス帳の連絡先のアドレスに基づいて、地図にピンを追加しています。私はいくつかのピン(おそらく2のうちの2つ)がマップビューにドロップしないいくつかの奇妙なケースを抱えています。私は有効なアドレスを確認しました。しかしピンは落ちていません。これの理由は何でしょうか。モバイルデバイスには、PCと比較して限られた数のピンしか表示されていません
for (i = 0; i<[groupContentArray count]; i++) {
person = ABAddressBookGetPersonWithRecordID(addressbook,[[groupContentArray objectAtIndex:i] intValue]);
ABMultiValueRef addressProperty = ABRecordCopyValue(person, kABPersonAddressProperty);
NSArray *address = (NSArray *)ABMultiValueCopyArrayOfAllValues(addressProperty);
NSLog(@"Address %@", address);
for (NSDictionary *addressDict in address)
{
addAnnotation = nil;
firstName = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
lastName = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
NSString *country = [addressDict objectForKey:@"Country"];
NSString *streetName = [addressDict objectForKey:@"Street"];
NSString *cityName = [addressDict objectForKey:@"City"];
NSString *stateName = [addressDict objectForKey:@"State"];
if (streetName == (id)[NSNull null] || streetName.length == 0) streetName = @"";
if (stateName == (id)[NSNull null] || stateName.length == 0) stateName = @"";
if (cityName == (id)[NSNull null] || cityName.length == 0) cityName = @"";
if (country == (id)[NSNull null] || country.length == 0) country = @"";
NSString *fullAddress = [streetName stringByAppendingFormat:@"%@/%@/%@", cityName, stateName, country];
mapCenter = [self getLocationFromAddressString:fullAddress];
if(stateName != NULL || country != NULL || streetName != NULL || cityName != NULL){
if ((mapCenter.latitude == 0) && (mapCenter.longitude == 0))
{
// Alert View
}
else{
addAnnotation = (MyAddressAnnotation *)[mapView dequeueReusableAnnotationViewWithIdentifier:[groupContentArray objectAtIndex:i]];
if(addAnnotation == nil){
addAnnotation = [[[MyAddressAnnotation alloc] initWithCoordinate:mapCenter title:firstName SubTitle:lastName Recordid:[groupContentArray objectAtIndex:i] ]autorelease];
[mapView addAnnotation:addAnnotation];}
}
}
}
CFRelease(addressProperty);
}
編集:私は自分の質問を編集しており、より具体的です。私はmapViewのピンを落とすコードを使用しています。私のMacのPC上で、20ピンがマップにドロップされる場合。 20ピンすべてが正確に落ちていて、正常に動作しています。しかし、私がIPhoneまたはIPadを使用しているとき、ピン数は大幅に減少します。つまり、私が落としている20ピンのうち、4ピンしか地図に表示されていません。私はこれの理由を理解することができません。
コーディングの一部を表示できますか? – HarshIT
あなたのコードがないと、私は何が間違っているかを言うことは不可能だと確信しています。言い換えれば、コードなどの情報を提供してください。 – Manuel
ハドリーと完全に同意します...コード化されたものを提供してください。 – Krunal