我正在加載地圖視圖。我正在根據地址簿中聯繫人的地址向地圖添加針腳。我遇到了一些奇怪的情況,其中一些針腳(可能是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 2012-03-27 12:13:53
沒有你的任何代碼我很確定不可能說出什麼是錯的。換句話說:請提供一些更多的信息,如代碼。 – Manuel 2012-03-27 12:14:40
完全同意哈德利...請提供你已編碼的東西。 – Krunal 2012-03-27 12:15:31