[英]Pushing a navigation controller after a modal view controller is presented
我有一個標簽視圖控制器,它有一個像這樣的按鈕,當它被按下時,會出現一個模態:
PostViewController *post = [[PostViewController alloc] init];
// [self.navigationController pushViewController:post animated:YES];
// Presentation
[self presentViewController:post animated:YES completion:nil];
當模態完成后,我想解除它並推送一個新的視圖控制器,如下所示:
ProfilesViewController *profile = [[ProfilesViewController alloc] init];
[self.navigationController pushViewController:profile animated:YES];
但我不能在后vc作為它的模態。 我該怎么做呢?
您可以嘗試使用completionBlock
。
當presentViewController CompletionBlock
調用CompletionBlock
。
PostViewController *post = [[PostViewController alloc] init];
[con presentViewController:post animated:YES completion:^{
ProfilesViewController *profile = [[ProfilesViewController alloc] init];
[self.navigationController pushViewController:profile animated:YES];
}];
有關presentViewController:animated:completion:
更多信息presentViewController:animated:completion:
Apple Doc
完成:演示完成后要執行的塊。 該塊沒有返回值,不帶參數。 您可以為此參數指定nil。
使用嵌入在UINavigationController中的選項卡視圖控制器? 如果還沒有,你當然不能使用self.navigationController。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.