我試圖從我當前的視圖控制器self
轉換爲self.aVC
使用視圖控制器遏制使用self.navigationController
作爲容器。當我運行下面的代碼時,「子視圖控制器必須有一個共同的父視圖控制器」錯誤彈出,但兩個NSLog顯示相同的parentViewController。transitionFromViewController:toViewController錯誤:子視圖控制器必須有一個共同的父視圖控制器
這似乎是什麼問題?任何幫助表示讚賞。
[self willMoveToParentViewController:nil];
[self.navigationController addChildViewController:self.aVC];
[self.aVC.view setFrame:self.bottomFrame];
NSLog(@"%@",self.parentViewController);
NSLog(@"%@",self.aVC.parentViewController);
// __weak __block SBSomeVC *weakSelf = self;
[self transitionFromViewController:self toViewController:self.aVC duration:0.3 options:UIViewAnimationOptionTransitionNone animations:^{
[self.aVC.view setFrame:self.view.bounds];
} completion:^(BOOL finished) {
[self.aVC didMoveToParentViewController:self.navigationController];
[self removeFromParentViewController];
}];