ABPersonViewController ...没有后退按钮

时间:2010-08-15 21:20:48

标签: iphone

我有一个基于“基于导航的应用程序”项目类型的简单项目。 RootViewController有一个行列表,其中包含一些联系人名称,还有一个按钮,可以通过ABPersonViewController将它们带到该联系人的详细信息页面。

我有所有的钩子工作,我通过在导航堆栈上推送它显示正确的ABPersonViewController ...但它没有后退按钮!该应用程序被卡住了,因为没有办法回到我的应用程序。如何启用后退按钮?希望得到一些帮助。

以下是相关代码:

- (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];
}

1 个答案:

答案 0 :(得分:2)

如果你找不到系统后退按钮,你可以自己创建一个。

- (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];
}
祝你好运=]

btw-如果您不喜欢“完成”按钮样式,您可以随时使用自定义按钮样式作为后退按钮箭头外观。