Z S
Z S

Reputation: 7491

ABPersonViewController ... no back button

I have a simple project based off the "Navigation Based application" project type. The RootViewController has a list of rows with some names for contacts, and a button which should take them to that contact's details page with ABPersonViewController.

I have all the hooks working and I show the correct ABPersonViewController by pushing it on the navigation stack... but it doesn't have a Back button! The app gets stuck because there's no way to get back to my app. How do I enable the back button? Would appreciate some help.

Here's the relevant code:

- (void) nameButtonClicked: (id) sender
{
    UIButton *button = (UIButton *) sender;
    NSLog(@"name button clicked... record_id = %i", button.tag);
    ABRecordRef contact_data = ABAddressBookGetPersonWithRecordID(address_book, button.tag);

    ABPersonViewController *ab = [[ABPersonViewController alloc] init];
    [ab setPersonViewDelegate:self];
    [ab setDisplayedPerson:contact_data];
    ab.allowsEditing = YES;
    [self.navigationController pushViewController:ab animated:YES];
    [ab release];
}

Upvotes: 1

Views: 1292

Answers (1)

eladyanai
eladyanai

Reputation: 1093

if you cant find the system back button you can always create one yourself.

- (void) nameButtonClicked: (id) sender
{
UIButton *button = (UIButton *) sender;
NSLog(@"name button clicked... record_id = %i", button.tag);
ABRecordRef contact_data = ABAddressBookGetPersonWithRecordID(address_book, button.tag);

ABPersonViewController *ab = [[ABPersonViewController alloc] init];
ab.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back",nil) style:UIBarButtonItemStyleDone target:self action:@selector(ReturnFromPersonView)];
[ab setPersonViewDelegate:self];
[ab setDisplayedPerson:contact_data];
ab.allowsEditing = YES;
[self.navigationController pushViewController:ab animated:YES];
[ab release];
}

- (void)ReturnFromPersonView{
[self.navigationController popViewControllerAnimated:YES];
}

good luck =]

btw- if you dont like the "done" button style, you can always use an custom button style for the back button arrow like look.

Upvotes: 2

Related Questions