マップビューを読み込んでいます。そして、アドレス帳の連絡先の住所に基づいて、地図にピンを追加しています。一部のピン(おそらく10個中2個)がマップビューにドロップしないという奇妙なケースがあります。有効な住所を確認しました。しかし、ピンは落ちていません。これの理由は何でしょうか。
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にピンをドロップしています。私のMacPCで、マップにドロップするピンが20個ある場合。20本のピンはすべて正確に落下し、正常に機能しています。しかし、iPhoneやiPadを使用していると、ピン数が大幅に減少します。つまり、私がドロップしている約20本のピンのうち、4本のピンだけがマップに表示されています。その理由がわかりません。