Show custom contact information

允我心安 提交于 2019-12-10 11:42:19

问题


So I have an MKMapView and I have a pin on it with a disclosure button. I want the user to be able to tap the disclosure button and the navigation controller to push a new view controller. But I want that new view controller to look like the contacts viewController that comes standard in the contacts app. I need it to display custom contact information because the contact will not be in the users contacts. I have been playing around with ABPerson, but I can't figure it out. I want that contact page to look exactly like the standard page. This is what I've been playing 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 really sure what to do. The contact information I want to display will include Business title, Address, Phone Number, and stuff like that.

Thank you very much in advance.


回答1:


Here is how it should be done:

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

and than to respond to the [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;
}


来源:https://stackoverflow.com/questions/6236820/show-custom-contact-information

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!