ABUnknownPersonViewController *unknownPersonViewController = [[ABUnknownPersonViewController alloc] init];
unknownPersonViewController.view.frame = CGRectMake(0, 20, 320, 400);
//unknownPersonViewController.displayedPerson = (ABRecordRef)[self buildContactDetails];
unknownPersonViewController.allowsAddingToAddressBook = YES;
UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
cancelBtn.frame = CGRectMake(262, 6, 54,30);
[unknownPersonViewController.view addSubview:cancelBtn];
[self presentModalViewController:unknownPersonViewController animated:YES];
[unknownPersonViewController release];
我正在使用UIViewcontroller,在这段代码中,我希望像导航栏这样的栏会显示在上面 这个控制器的一面所以我想在那个栏上放上取消按钮。有什么帮助吗?
答案 0 :(得分:2)
您应该做的是将您的ABUnknownPersonViewController
嵌入到UINavigationController
UINavigationController *newNavigationController = [[UINavigationController alloc] initWithRootViewController:unknownPersonViewController];
[self presentModalViewController:newNavigationController animated:YES];
[view release];
[newNavigationController release];
这样你甚至不必自己添加按钮,ABUnknownPersonViewController
会照顾你。
有关详情,请查看Address Book Programming
答案 1 :(得分:0)
嗯,在线文档说“重要的未知人员视图控制器必须与导航控制器一起使用才能正常运行。”因此,与许多实用程序视图控制器不同,我认为您不应该调用
[self presentModalViewController:unknownPersonViewController animated:YES];
而是
[self.navigationController pushViewController:view animated:YES];
我想如果你看看他们的样品,你会看到他们推动使用导航控制器。