gpt4 book ai didi

iphone - 在 peoplePickerNavigationController 中选择联系人后呈现 viewController?

转载 作者:行者123 更新时间:2023-12-03 19:40:05 24 4
gpt4 key购买 nike

我遇到了一个小问题 -

(顺便说一句,我看过 How can I present a modal view controller after selecting a contact?但这对我没有帮助)

基本上我想让用户使用 - peoplePickerNavigationController 选择联系人。选择后我想呈现将使用 personRef 数据的ModalViewController。我可以看到“添加人员”方法被调用,但 iphone 不显示 View 。

更新 - 如果我取消 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;
}

这是调用的函数,但 View 仍然没有呈现 -

- (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];
}

非常感谢。

最佳答案

只是不要关闭人员选择器并在其之上以模态方式显示您的 Controller 。如果您随后在某个时候关闭 Controller ,则关闭人员选择器(来自调用者/父级),并且您的 ViewController 也将被关闭。

来自苹果文档:

dismissModalViewControllerAnimated: … If you present several modal view controllers in succession, and thus build a stack of modal view controllers, calling this method on a view controller lower in the stack dismisses its immediate child view controller and all view controllers above that child on the stack. When this happens, only the top-most view is dismissed in an animated fashion; any intermediate view controllers are simply removed from the stack.

关于iphone - 在 peoplePickerNavigationController 中选择联系人后呈现 viewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4794307/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com