簡體   English   中英

導航和標簽欄控制器未顯示

[英]Navigation and Tab Bar Controller not showing up

我試圖在應用程序委托中使用InstantiateViewControllerWithIdentifier來顯示視圖控制器,但由於某些原因,導航欄和選項卡欄沒有顯示。 我不確定自己在做什么錯-謝謝

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController *view = (UINavigationController *)[sb instantiateViewControllerWithIdentifier:@"ShopViewController"];
self.window.rootViewController = view;

ShopViewController是UINavigation控制器還是僅僅是視圖控制器。 聽起來您好像在將視圖控制器聲明為uinavigationcontroller。 相反,您應該將導航控制器放在情節提要上,然后提供一個標識符,或者您可以只在應用程序委托中創建導航控制器。

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ShopViewController *showViewController = (ShopViewController *)[sb instantiateViewControllerWithIdentifier:@"ShopViewController"];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:shopViewController];
self.window.rootViewController = nav;

暫無
暫無

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

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