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

标签 iphone addressbook presentmodalviewcontroller

我遇到了一个小问题 -

(顺便说一句,我看过 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/

相关文章:

iphone - 构建适用于iOS 7,但在iOS 6中崩溃

iphone - 如何解决 ABPeoplePickerNavigationController 中缺少 'add' 按钮的问题?

javascript - Codecademy Javascript 类(class)构建地址簿 3/6

swift - 如何关闭模态视图之外的 modalView

iOS ABPersonViewController

ios - 无法删除有关 iOS 6 中已弃用方法的警告

iphone - 如何防止UItable View 的tableHeaderView滚动,粘在顶部

iphone - 我如何完全杀死一个 View Controller ?

iphone - 调整 UIWebView 大小时抗锯齿不起作用

ios - 找不到 'ABPeoplePickerNavigationControllerDelegate' 的协议(protocol)声明