Can I push a modal view controller from within another modal view controller?

Discussion in 'iOS Programming' started by ataylor2009, Mar 30, 2010.

  1. ataylor2009 macrumors member

    Joined:
    Jan 27, 2009
    #1
    I've got a rootViewController that, at one point, displays a peoplePickerNavigationController. I'm trying to push a second view controller when my user selects a specific contact property, like so:

    Code:
    -(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)picker shouldContinueAfterSelectingPerson:(ABPersonRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
    RuleBuilder *ruleBuilder = [[RuleBuilder alloc] initWithNibName:@"RuleBuilder" bundle:nil];
    [self pushModalViewController:ruleBuilder animated:YES];
    [ruleBuilder release];
    return NO;
    }
    This compiles just fine, but when I run the code in the simulator and run through the peoplePicker, nothing happens when I select a contact property. On a whim, I added a [self dismissModalViewControllerAnimated:YES]; just before [ruleBuilder release]; and that dismisses the peoplePicker, but otherwise has no effect on my missing ruleBuilder.

    Any ideas?
     
  2. ataylor2009 thread starter macrumors member

    Joined:
    Jan 27, 2009
    #2
    Found the answer:

    Code:
    [picker pushModalViewController:ruleBuilder animated:YES];
    I was sending the message to 'self' (the rootViewController) instead of 'picker' (the active view controller). Whoops.
     

Share This Page