我使用一些引脚加载MKMapView
,这些引脚根据地址坐标丢弃。一切正常,直到我将mapview打开一段时间(2分钟)。然后它崩溃,没有事件发生。这可能是什么原因。MapVIew中的崩溃
在我viewDidLoad中我写了下面的代码
mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
mapView.delegate=self;
[self.view addSubview:mapView];
addressbook = ABAddressBookCreate();
for (i = 0; i<[groupContentArray count]; i++) {
NSLog(@"group content array %@", groupContentArray);
person = ABAddressBookGetPersonWithRecordID(addressbook,[[groupContentArray objectAtIndex:i] intValue]);
NSLog(@"Person %@", person);
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{
if(addAnnotation == nil){
addAnnotation = [[[MyAddressAnnotation alloc] initWithCoordinate:mapCenter title:firstName SubTitle:lastName Recordid:[groupContentArray objectAtIndex:i] ]autorelease];
[mapView addAnnotation:addAnnotation];}
else{
// ALert View
}
}
}
}
CFRelease(addressProperty);
}
[self zoomToFitMapAnnotations:mapView];
[self.navigationItem setHidesBackButton:YES animated:YES];
NSString *mapTitle = localizedString(@"MAP_TITLE");
[self setTitle:mapTitle];
[segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
你可以发布与崩溃相关的任何错误或者可能是一些代码行吗? – simonbs 2012-04-13 04:36:57
发布一些代码和错误屏幕截图会帮助我们来帮助你。 :-) – 2012-04-13 04:41:15
尝试调试你的代码或在这里发布一些代码,这样其他人会看到并给你答案 – 2012-04-13 04:54:12