Wann addChildViewController

Ich versuche, etwas zu haben, ähnlich wie ein UINavigationController, so kann ich passen Sie die Animationen. Um zu beginnen, ich bin nur mit den Apple-Aktien-Animationen. Hier ist meine containerViewController:

- (void)loadView {
    //Set up content view
    CGRect frame = [[UIScreen mainScreen] bounds];
    _containerView = [[UIView alloc] initWithFrame:frame];
    _containerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    self.view = _containerView;

}

- (id)initWithInitialViewController:(UIViewController *)vc {
    self = [super init];
    if (self) {
        _currentViewController = vc;

        [self addChildViewController:_currentViewController];
        [self.view addSubview:_currentViewController.view];
        [self didMoveToParentViewController:self];

        _subViewControllers = [[NSMutableArray alloc] initWithObjects:_currentViewController, nil];
    }
    return self;
}



- (void)pushChildViewController:(UIViewController *)vc animation:(UIViewAnimationOptions)animation {
    vc.view.frame = _containerView.frame;
    [self addChildViewController:vc];

    [self transitionFromViewController:_currentViewController toViewController:vc duration:0.3 options:animation animations:^{

    }completion:^(BOOL finished) {
        [self.view addSubview:vc.view];
        [vc didMoveToParentViewController:self];
        [self.subViewControllers addObject:vc];
    }];
}

- (void)popChildViewController:(UIViewController *)vc WithAnimation:(UIViewAnimationOptions)animation {
    //Check that there is a view controller to pop to
    if ([self.subViewControllers count] <= 0) {
        return;
    }

    NSInteger idx = [self.subViewControllers count] - 1;
    UIViewController *toViewController = [_subViewControllers objectAtIndex:idx];
    [vc willMoveToParentViewController:nil];

    [self transitionFromViewController:vc toViewController:toViewController duration:0.3 options:animation animations:^{

    }completion:^(BOOL finished) {
        [vc.view removeFromSuperview];
        [vc removeFromParentViewController];
        [self didMoveToParentViewController:toViewController];
        [self.subViewControllers removeObjectAtIndex:idx];
    }];
}

Habe ich diese ContainerViewcontroller als meine rootViewController des Fensters. Ich kann hinzufügen, meine Initialen viewController und schieben Sie einen view-controller. Wenn ich versuche zu pop, obwohl, ich bekomme

ContainerViewController[65240:c07] Unbalanced calls to begin/end appearance transitions for <SecondViewController: 0x8072130>.

Frage ich mich, was ich falsch mache. Ich dachte, meine initialViewController ist noch unterhalb der secondViewController. Irgendwelche Gedanken? Danke!

InformationsquelleAutor Crystal | 2012-12-07
Schreibe einen Kommentar