2010-08-15 155 views
1

我有一个基于“基于导航的应用程序”项目类型的简单项目。 RootViewController有一个包含联系人姓名的行列表,以及一个按钮,它应该将他们带到ABPersonViewController的联系人详细信息页面。ABPersonViewController ...没有后退按钮

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

下面是相关代码:

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

回答

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-如果你不喜欢的“完成”按钮样式,你可以随时使用的自定义按钮样式后退按钮箭头般的外观。