MKMapView
에는 주소 좌표에 따라 몇 개의 핀이 있습니다. 모든 것이 제대로 작동 할 때까지지도보기를 언젠가 (2 분) 열어 둔다. 그리고 실제로 일어나는 사건없이 충돌합니다. 이것에 대한 이유는 무엇 일 수 있습니다. 내 viewDidLoad에에서MapVIew에서 충돌이 발생했습니다.
나는이 시도 다음 코드를
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
일부 코드 및 오류 스크린 샷을 게시하면 도움을 얻을 수 있습니다. :-) –
코드를 디버깅하거나 다른 사람들이 귀하에게 대답을 줄 수 있도록 여기에 코드를 게시 해보십시오. –