The viewController after contact has been selected in peoplePickerNavigationController?

I have a little problem -

(By the way, I looked. How can I present a modal view controller after selecting a contact? But this did not help me)

Basically I want the user to select a contact with - peoplePickerNavigationController. after selecting I want to introduce a ModalViewController that will use the personRef data. I see that the "add person" method is being called, but the iphone does not represent the view.

UPDATE - . This works if I cancel the animation in Dismiss rejectModalViewControllerAnimated and in the present ModalViewController, but then it looks pretty ugly.

this is a function called after the user selects a 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 a function called, but still the view is not displayed -

- (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 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.

+3
source share
3 answers

Just do not fire the people picker and do not put your controller in order on top of it. If after this you dismiss your dispatcher, at some point release the people dispatcher instead (from the caller / parent), and your ViewController will also be fired.

From Apple docs:

rejectModalViewControllerAnimated:... , , , . , ; .

+3

, , , , ,

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person {

    [self.navigationController dismissViewControllerAnimated:YES completion:^{

        ContactDetailViewController * vc = [[ContactDetailViewController alloc] initWithWithABRecord:person];
        vc.delegate = self;
        UINavigationController * nc = [[UINavigationController alloc] initWithRootViewController:vc];
        [self.navigationController presentViewController:nc animated:YES completion:^{

        }];

    }];

}
+2

I suppose you just need to wait until the people collector disappears, having finished the animation that it points out by calling viewDidDisappear. If you override and plug in there, you must save it in order to introduce your modal controller.

0
source

Source: https://habr.com/ru/post/1787698/


All Articles