ios - transitionFromViewController view not appearing -
i have following code replace 1 view in container view corresponding container view controller. copied apple documentation.
edit: apple documentation creating custom container view controllers
- (void)transitiontoviewcontroller:(uiviewcontroller*)toviewcontroller { toviewcontroller.view.autoresizingmask = uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleheight; [self.childviewcontroller willmovetoparentviewcontroller:nil]; [self addchildviewcontroller:toviewcontroller]; // [self.view addsubview:toviewcontroller.view]; toviewcontroller.view.frame = cgrectoffset(self.view.bounds, self.view.frame.size.width, 0); [self transitionfromviewcontroller:self.childviewcontroller toviewcontroller:toviewcontroller duration:0.5 options:0 animations:^{ toviewcontroller.view.frame = self.view.bounds; } completion: ^(bool finished) { nslog(@"finished: %d", finished); [self.childviewcontroller removefromparentviewcontroller]; [toviewcontroller didmovetoparentviewcontroller:self]; self.childviewcontroller = toviewcontroller; }]; } when executed, toviewcontroller.view not appear. however, viewwillappear , viewdidappear getting called in toviewcontroller.view. in completion block, value of finished false. not working correctly.
i know transitionfromviewcontroller add toviewcontroller.view view hierarchy. if uncomment line addsubview manually adding it, view appear, appearance methods on view getting called multiple times. , in case finished value in completion block true.
welcomeviewcontroller viewwillappear welcomeviewcontroller viewwillappear welcomeviewcontroller viewdidappear finished: 1 welcomeviewcontroller viewdidappear i'm pretty sure should not manually adding view view hierarchy based on several other examples. why isn't working?
turned out code above correct , problem elsewhere. problem first time through transition, self.childviewcontroller.view not in view hierarchy. self.childviewcontroller in view controller hierarchy view not.
Comments
Post a Comment