Iphone 与PC相比,移动设备中显示的引脚数量有限
我正在加载地图视图。我根据通讯录中联系人的地址在地图上添加PIN。我遇到了一些奇怪的情况,其中一些引脚(可能是10个引脚中的2个)没有在地图视图中出现。我查过地址了,地址是有效的。但大头针没有掉下来。这可能是什么原因呢Iphone 与PC相比,移动设备中显示的引脚数量有限,iphone,ios,mkmapview,pins,Iphone,Ios,Mkmapview,Pins,我正在加载地图视图。我根据通讯录中联系人的地址在地图上添加PIN。我遇到了一些奇怪的情况,其中一些引脚(可能是10个引脚中的2个)没有在地图视图中出现。我查过地址了,地址是有效的。但大头针没有掉下来。这可能是什么原因呢 for (i = 0; i<[groupContentArray count]; i++) { person = ABAddressBookGetPersonWithRecordID(addressbook,[[groupContentArray o
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);
}
对于(i=0;i此代码:
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];
}
}
毫无意义
dequeueReusableAnnotationViewWithIdentifier
方法用于将MKAnnotationView
对象(而不是id
对象)排挤出队列
出列代码属于viewForAnnotation
delegate方法,但不属于此处
在这里,您只需创建注释对象(MyAddressAnnotation
)并对其调用addAnnotation
)
我还强烈建议您将注释变量的名称从addAnnotation
更改为其他名称,这样您就不会将其与地图视图的方法addAnnotationMy bad混淆。在我使用的“fulladdress”字符串(streetName和cityName之间)中,没有用空格或“、”或“/”分隔。因此,一些地址没有被识别。你能展示一些编码吗?如果没有任何编码,我很确定不可能说出错误所在。换句话说:请提供更多信息,如编码。完全同意哈德利的观点……请提供你编码的内容……我能为你做些什么吗e地图加载速度更快。现在加载速度太慢。