我遇到了问题。 ABUnknownPersonViewController嵌入在顶视图的导航控制器中,但是,我没有在我的应用程序中使用导航栏。当推送到ABUnknownPersonView时,我没有得到导航栏或后退按钮。我的解决方案是:
ABUnknownPersonViewController *unknownPersonViewController = [[ABUnknownPersonViewController alloc] init];
unknownPersonViewController.displayedPerson = (ABRecordRef)[self buildContactDetails];
unknownPersonViewController.allowsAddingToAddressBook = YES;
unknownPersonViewController.unknownPersonViewDelegate = self;
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 41)]; navBar.delegate = self;
UINavigationItem *backItem = [[UINavigationItem alloc] initWithTitle:@"Back"];
[navBar pushNavigationItem:backItem animated:NO];
UINavigationItem *topItem = [[UINavigationItem alloc] initWithTitle:@"Your Title"];
[navBar pushNavigationItem:topItem animated:NO];
topItem.leftBarButtonItem = nil;
[unknownPersonViewController.view addSubview:navBar];
[self.navigationController pushViewController:unknownPersonViewController animated:YES];
所以这会在导航栏中添加,但后退按钮除了将标题更改为“后退”之外什么都不做...非常有帮助大声笑。另外,我的导航栏顶部没有界限,所以我有点困难......下面的图片
答案 0 :(得分:2)
您可以尝试以这种方式呈现它。我也没有在主视图中使用导航栏。这将在左上角添加一个取消按钮。
ABUnknownPersonViewController *view = [[ABUnknownPersonViewController alloc] init];
view.unknownPersonViewDelegate = self;
//Add person record data
view.displayedPerson = person;
view.allowsAddingToAddressBook = YES;
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:view];
view.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self
action:@selector(dismissContactView:)];
[self presentViewController:nav animated:YES completion:nil];