在 peoplePickerNavigationController 中选择联系人后呈现 viewController?
我遇到了一个小问题 -
(顺便说一句,我看过 如何呈现模式视图控制器选择联系人后? 但这对我没有帮助)
基本上我想让用户使用 - peoplePickerNavigationController 选择联系人。选择后我想呈现将使用 personRef 数据的ModalViewController。 我可以看到“添加人员”方法被调用,但 iPhone 不显示视图。
更新 - 如果我取消 DismissmissModalViewControllerAnimated 和 PresentModalViewController 中的动画,它会起作用,但它看起来很丑陋。
这是用户选择联系人后调用的函数 -
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)personRef {
TempREcordId = ABRecordGetRecordID(personRef);
BOOL hasDeleteDate = [GlobalFunctions CheckToSeeIfInHiBye:TempREcordId];
if (hasDeleteDate) {
[GlobalFunctions alert:NSLocalizedString(@"", @"") ];
}else{
[self addCustomValuesAfterSelection];
[self dismissModalViewControllerAnimated:YES];
}
return NO;
}
这是调用的函数,但视图仍然没有呈现 -
- (void)addPerson {
NSLog(@"@2");
AddViewController *addViewController = [[AddViewController alloc] initWithStyle:UITableViewStyleGrouped];
addViewController.delegate = self;
// Create a new managed object context for the new book -- set its persistent store coordinator to the same as that from the fetched results controller's context.
NSManagedObjectContext *addingContext = [[NSManagedObjectContext alloc] init];
self.addingManagedObjectContext = addingContext;
[addingContext release];
[addingManagedObjectContext setPersistentStoreCoordinator:[[fetchedResultsController managedObjectContext] persistentStoreCoordinator]];
addViewController.person = (Person *)[NSEntityDescription insertNewObjectForEntityForName:@"Person" inManagedObjectContext:addingContext];
addViewController.hiByeGroupId = [dataSource hibyeGroupId];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addViewController];
[self.navigationController presentModalViewController:navController animated:YES];
[addViewController release];
[navController release];
}
非常感谢。
I am having a little problem -
(BTW i have looked on
How can I present a modal view controller after selecting a contact?
but it didnt help me)
Basically i want to let the user select a contact using the - peoplePickerNavigationController. after the selection i want to presentModalViewController that will use the personRef data.
i can see that the "add person" method get called but the iphone does not present the view.
UPDATE - It works if i cancel the animation in the Dismiss dismissModalViewControllerAnimated and in the presentModalViewController, but then it looks pretty ugly.
this is the function called after the user selects the contact -
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)personRef {
TempREcordId = ABRecordGetRecordID(personRef);
BOOL hasDeleteDate = [GlobalFunctions CheckToSeeIfInHiBye:TempREcordId];
if (hasDeleteDate) {
[GlobalFunctions alert:NSLocalizedString(@"", @"") ];
}else{
[self addCustomValuesAfterSelection];
[self dismissModalViewControllerAnimated:YES];
}
return NO;
}
this is the function called but still the view is not presenting -
- (void)addPerson {
NSLog(@"@2");
AddViewController *addViewController = [[AddViewController alloc] initWithStyle:UITableViewStyleGrouped];
addViewController.delegate = self;
// Create a new managed object context for the new book -- set its persistent store coordinator to the same as that from the fetched results controller's context.
NSManagedObjectContext *addingContext = [[NSManagedObjectContext alloc] init];
self.addingManagedObjectContext = addingContext;
[addingContext release];
[addingManagedObjectContext setPersistentStoreCoordinator:[[fetchedResultsController managedObjectContext] persistentStoreCoordinator]];
addViewController.person = (Person *)[NSEntityDescription insertNewObjectForEntityForName:@"Person" inManagedObjectContext:addingContext];
addViewController.hiByeGroupId = [dataSource hibyeGroupId];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addViewController];
[self.navigationController presentModalViewController:navController animated:YES];
[addViewController release];
[navController release];
}
thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只是不要忽略人员选择器并将您的控制器以模态方式显示在其之上。如果您随后在某个时候关闭控制器,则关闭人员选择器(来自调用者/父级),并且您的 ViewController 也将被关闭。
来自苹果文档:
Just don't dismiss the people picker and present your controller modally on top of it. If you afterwards dismiss your controller at some point dismiss the people picker instead (from the caller/parent) and your ViewController will be dismissed too.
From the Apple Docs:
虽然通过选择一个人,选择器会关闭,但关键是在选择一个人之后,在委托回调中自行关闭它,而不是呈现你的控制器
Although by picking a person, the picker dismisses, the key is to dismiss it yourself in the delegate callback, after picking a person and than present your controller
我想你只需要等待人物选择器通过完成其动画而消失,它是通过调用 viewDidDisappear 来指示的。如果您覆盖并连接在那里,您应该保存以显示您的模态控制器。
I suppose you just have to wait until the people picker disappeared by finishing its animation which it indicates by calling
viewDidDisappear
. If you override and hook up in there, you should be save to present your modal controller.