开发者

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开发者_StackOverflow中文版 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];
}


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜