簡體   English   中英

如何在標簽欄控制器中從一個視圖控制器切換到另一個視圖控制器並保留標簽欄?

[英]How within a tab bar controller do I segue from one view controller to another and retain the tab bar?

我有一個應用程序,其中有幾個視圖控制器由標簽欄控制器控制。 從我想要的其中一個視圖控制器(在單擊按鈕上)轉到另一個視圖控制器並保留要查看的segued底部的標簽欄。

我用過

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if ([segue.identifier isEqualToString:@"newView"]){
        UIViewController *controller =segue.destinationViewController;
        controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        [self presentModalViewController:controller animated:YES];
    }
 }

這樣工作正常,除了從視圖到視圖中缺少標簽欄(占位符在故事板中顯示它,但在應用程序運行時它不會顯示)我也嘗試過更換

[self presentModalViewController:controller animated:YES];

[self presentViewController:controller animated:YES completion:nil];

但這也不起作用。

一些調試顯示,對於segued-to視圖控制器,tabBarController屬性設置為nil。

反正有沒有保留標簽欄在segued-to視圖控制器?

根據你的解釋,我不認為你想要一個模態控制器。 模態用於疊加,使標簽欄無效。 從故事板中,選擇您的segue並選擇推送,而不是模態。

在此輸入圖像描述

Push vs Modal(注意標簽欄):

在此輸入圖像描述在此輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM