Show contact info

So, I have MKMapView , and I have a button with a disclosure button. I want the user to be able to click the open button and the navigation controller to click the new view controller. But I want the new view controller to look like viewController contacts, which are part of the standard contacts application. I need to display user contact details because the contact will not be in the users contacts. I played with ABPerson, but I can't figure it out. I want the contact page to look exactly like the standard page. This is what I played with:

  ABPersonViewController *view = [[ABPersonViewController alloc] init]; ABPerson *person; ABRecordRef ABPersonCreate ( void ); view.personViewDelegate = self; view.displayedPerson = person; view.allowsEditing = NO; [self.navigationController pushViewController:view animated:YES]; [view release]; 

I'm not sure what to do. The contact information I want to display will include the name of the business, address, phone number, etc.

Thank you in advance.

+1
source share
1 answer

Here's how it should be done:

  ABUnknownPersonViewController *newPersonViewController = [[ABUnknownPersonViewController alloc] init]; newPersonViewController.displayedPerson = [self personObject]; [self.navigationController pushViewController:newPersonViewController animated:YES]; 

and how to respond to [self personObject]

 - (ABRecordRef)personObject { // Create a new Person object. ABRecordRef newRecord = ABPersonCreate(); // Setting the value to the ABPerson object. //ABRecordSetValue(newRecord, kABPersonKindOrganization, @"Business Name", nil); ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutable(kABMultiStringPropertyType); ABMultiValueAddValueAndLabel(multiPhone, @"1-555-555-5555", kABPersonPhoneMainLabel, NULL); ABRecordSetValue(newRecord, kABPersonPhoneProperty, multiPhone,nil); CFRelease(multiPhone); return newRecord; } 
+2
source

Source: https://habr.com/ru/post/895998/


All Articles