我擺弄一些代碼試圖讓UIViewController遏制工作(在iPad應用程序中)。UIViewController遏制崩潰
該場景如下:我有一個觀點,我想顯示第二個視圖的頂部。我想有第二個(不同的)UIViewController管理與第二個視圖的所有交互。第一個視圖將按下按鈕加載第二個視圖。當按下按鈕下面的代碼在第一控制器上運行:
-(void)displayPropertyView // <-button triggers this
{
// Need to instantiate a new view and add it to the main editor view.
HPSQuestionListController* questionListController = [ [ HPSQuestionListController alloc ] init ];
[self.view addSubview:questionListController.view];
[self.view bringSubviewToFront:questionListController.view];
[self pushViewController:questionListController animated:YES];
}
-(void)pushViewController:(UIViewController*)controller animated:(BOOL)animated
{
[self addChildViewController:controller];
//[controller didMoveToParentViewController:self];
if (YES)
{
[self transitionFromViewController:self
toViewController:controller
duration:1.0
options:nil
animations:^{}
completion:^(BOOL finished){
[controller didMoveToParentViewController:self];
}];
}
}
在transitionFromViewController行中的應用程序崩潰與:
兒童視圖控制器和 必須有共同的父視圖 控制器時電話 - [UIViewController中 transitionFromViewController:toViewController:持續時間:選擇:動畫:完成:]」
任何人都知道如何解決這個問題?我對UIViewController遏制的理解是,我可以有兩個控制器同時管理兩個視圖。這是錯的嗎?