我有一个简单的项目基于“基于导航的应用程序”项目类型。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];
}发布于 2011-06-19 18:57:47
如果你找不到系统的后退按钮,你可以自己创建一个。
- (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];
}好运=]
顺便说一句,如果你不喜欢“完成”按钮样式,你可以随时使用一个自定义的按钮样式的后退按钮箭头的外观。
https://stackoverflow.com/questions/3489317
复制相似问题