我正在使用 AddressBookUI 框架添加联系人,当我尝试推送此 View Controller 然后取消并完成按钮无法正常工作时,我不想展示它
这是我的代码
ABNewPersonViewController *abnpvc = [[ABNewPersonViewController alloc] init];
[abnpvc setNewPersonViewDelegate: self];
[self.navigationController pushViewController:abnpvc animated:YES];
我也尝试添加为 subview 而不是推送它,但是当我添加为 subview 时它没有被添加
根据评论,我已经尝试过
UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:abnpvc];
[self presentViewController:navigation animated:YES completion:nil];
谁能帮我看看为什么不能正常工作?
您也可以考虑 iOS 9 中的其他答案和对 ABNewPersonViewController
的弃用。
根据您的意见:
cancel and done button not working properly
如果您在这样的界面上包含 ABNewPersonViewControllerDelegate
,它们就可以工作:
@interface ViewController () <ABNewPersonViewControllerDelegate>
像这样将 viewController 推送到导航堆栈上:
ABNewPersonViewController *controller = [[ABNewPersonViewController alloc] init];
controller.newPersonViewDelegate = self;
[self.navigationController pushViewController:controller animated:YES];
并且通过实现这个方法来符合协议(protocol):
- (void)newPersonViewControllerABNewPersonViewController *)newPersonView didCompleteWithNewPersonnullable ABRecordRef)person {
// Trick to go back to your view by popping it from the navigation stack when done or cancel button is pressed
[self.navigationController popViewControllerAnimated:YES];
}
当按下 Done 或 Cancel 按钮时,棘手的问题是从导航堆栈中弹出 newPersonController。
好好享受吧
关于ios - 推送 ABNewPersonViewController 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35722898/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (https://ogeek.cn/) | Powered by Discuz! X3.4 |