views:

549

answers:

3

I'm showing an ABPeoplePickerNavigationController as a tab in my app. The user clicks a name, then email address, then I do something with the email address.

Afterwards, I'd like for the person and property that they selected to fade out (not be highlighted).

In a normal table, I'd call deselectRowAtIndexPath. But with the ABPeoplePickerNavCont I don't seem to have access to it's table, nor do I know what indexPath is selected, nor is there an api for deselecting the row.

On most apps, ABPeoplePickerNavCont is used modally so it doesn't matter that the row is still highlighted 'cause the whole thing gets dismissed. But in my app it does not get dismissed (just like the contacts tab in the Phone app).

Any ideas?

A: 

dismiss the peoplepicker without an animation, then present it again without animation. It looks good.

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person{

    [self dismissModalViewControllerAnimated:NO];

    [self presentModalViewController:peoplePicker animated:NO];
        return NO;
 }
John Anderson
Thanks for the suggestion. My peoplePicker is not being shown as a modal - it is a tab on a tab bar... so it's not possible to dismiss it in this way.
Josh Wright
A: 

This is what I'm doing... and it seems to work perfectly. I'm also adding a checkmark accessory when you select/deselect an item. Let me know what you think. Thanks :)

UIView *view = peoplePicker.topViewController.view;
UITableView *tableView = nil;
for(UIView *uv in view.subviews)
{
    if([uv isKindOfClass:[UITableView class]])
    {
        tableView = (UITableView*)uv;
        break;
    }
}

if(tableView != nil)
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:[tableView indexPathForSelectedRow]];

    cell.accessoryType = cell.accessoryType == UITableViewCellAccessoryNone ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;

    [cell setSelected:NO animated:YES];
}
robby valles
A: 

Thank you Robby Valles !!

Nice tip

Kenzo