ABPersonViewController won't show on Push

610 views Asked by At

So here's the scenarion, I've got a SearchController that displays filtered results from my apps list of contacts and that present in my addressbook as well.

The code that pushes the ABPersonViewController is present in my didSelectObject:atIndex method. here is the code:

TableCellClass *selectedCell= (TableCellClass *)[self.tableView cellForRowAtIndexPath:indexPath];

ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef arrayOfAllPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
ABRecordRef thisPerson = CFArrayGetValueAtIndex(arrayOfAllPeople,selectedCell.contactIndex);
ABPersonViewController *picker = [[ABPersonViewController alloc]init];
picker.personViewDelegate = self;
picker.displayedPerson = thisPerson;
picker.allowsEditing = YES;
[self.navigationController pushViewController:picker animated:YES];

This code block works just fine on a standard TTTableViewController, but somehow won't work on my searchController.

enter image description here

Here is the screen shot by the way. So as you can see there is no NavigationController present. This is default by Three20. The cell with the addressbook icon is the Item which launches the ABPersonViewController upon tap-gesture

2

There are 2 answers

0
BearDroid On BEST ANSWER

So I found a workaround to my problem.

First, I created a class that is a subclass of ABPersonViewController. Then created my own -initWithNavigatorURL:query: method.

on the TTTableViewController class that is my SearchDisplayController, inside the -didSelectObject:atIndexPath: method, i have this block of code:

TTTableItemCell *selectedCell= (TTTableItemCell *)[self.tableView cellForRowAtIndexPath:indexPath];

ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef arrayOfAllPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);

ABRecordRef thisPerson = CFArrayGetValueAtIndex(arrayOfAllPeople,selectedCell.contactIndex);
ABPersonViewController *picker = [[ABPersonViewController alloc]initWithNibName:nil bundle:[NSBundle mainBundle]];
picker.personViewDelegate = self;
picker.displayedPerson = thisPerson;
picker.allowsEditing = YES;

NSNumber *allowsEditing;

if (picker.allowsEditing) {
    allowsEditing = [[NSNumber alloc]initWithInt:1];
}
else{
    allowsEditing = [[NSNumber alloc]initWithInt:0];
}

TTURLAction *urlAction = [[[TTURLAction alloc] initWithURLPath:@"tt://GJABPersonView"] autorelease];
urlAction.query = [NSDictionary dictionaryWithObjects:[NSMutableArray arrayWithObjects:self, thisPerson,allowsEditing, nil] forKeys:[NSMutableArray arrayWithObjects:@"personViewDelegate",@"displayedPerson",@"allowsEditing", nil]];
urlAction.animated = YES;
[[TTNavigator navigator] openURLAction:[urlAction applyTransition:UIViewAnimationTransitionFlipFromLeft]];
[allowsEditing release];

It doesn't animate like it normally does when navigating but it does the work :)

2
railwayparade On

How is your searchController presented? Does it have a navigation controller?

Check that self.navigationController is not nil.