开发者

iOS ABPersonViewController

开发者 https://www.devze.com 2023-04-04 18:59 出处:网络
I have a tab bar app and in the first tab I have some buttons and a table view which is populated with contact info from Address Book. I am trying to show the contact info using the ABPersonViewContro

I have a tab bar app and in the first tab I have some buttons and a table view which is populated with contact info from Address Book. I am trying to show the contact info using the ABPersonViewController as a modal view when the accessory button of a cell is tapped. I am able to show the contact info but there is no cancel button to dismiss the modal view. Can someone look at the code below and let me know what I am missing.

ABRecordRef person = (ABRecordRef)[[self peopleList] objectAtIndex:[indexPath ro开发者_运维问答w]];
if (ABRecordGetRecordID(person) != kABRecordInvalidID)
{
    ABPersonViewController *personViewController = [[ABPersonViewController alloc] 
                           init];
   personViewController.displayedPerson = person;
    personViewController.allowsActions = YES;
   personViewController.navigationItem.title=@"Contact Info";   
   UINavigationController *navigationController = 
            [[UINavigationController alloc]initWithRootViewController:personViewController];
    [self presentModalViewController:navigationController animated:YES];
    [personViewController release];
}      


Per the docs, "Person view controllers must be used with a navigation controller in order to function properly."

ABPersonViewController *personViewController = [[ABPersonViewController alloc] init];
personViewController.personViewDelegate = self;
personViewController.displayedPerson = person;
personViewController.allowsAction = YES;
personViewController.navigationItem.title=@"Contact Info";

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:personViewController];

[self presentViewController:navController animated:YES completion:NULL];
0

精彩评论

暂无评论...
验证码 换一张
取 消