我正在推送推送通知。現在,當應用程序被提升到設備和當我點擊它。我想將3個ViewController推送到導航堆棧。從AppDelegate在NavigationController中推送3個以上的ViewController應用程序崩潰
所以我使用下面的代碼來做到這一點。
AppDelegate.cs代碼
Window = new UIWindow(UIScreen.MainScreen.Bounds);
Menu = new SlideoutNavigationController();
var storyboard = UIStoryboard.FromName("Main", null);
var webController = storyboard.InstantiateViewController("DashBoardViewController") as DashBoardViewController;
Menu.MainViewController = new MainNavigationController(webController, Menu);
Menu.MenuViewController = new MenuNavigationController(new DummyControllerLeft(), Menu) { NavigationBarHidden = false };
Window.RootViewController = Menu;
Window.MakeKeyAndVisible();
var storyboarddd = UIStoryboard.FromName("Main", null);
var webControllerdd = storyboarddd.InstantiateViewController("DashBoardViewController") as DashBoardViewController;
webControllerdd.reloadNotication();
UINavigationController nav = webController.NavigationController;
var notifyWebController = storyboard.InstantiateViewController("NotificationListViewController") as NotificationListViewController;
notifyWebController.navigationContoller = nav;
nav.PushViewController(notifyWebController, true);
if (type.Equals("Damage Report"))
{
var webController2 = storyboard.InstantiateViewController("DamageReportViewController") as DamageReportViewController;
webController2.DamageReportId = id;
webController2.navigationContoller = nav;
nav.PushViewController(webController2, true);
}
if (type.Equals("Overloss"))
{
var webController2 = storyboard.InstantiateViewController("OverlossViewController") as OverlossViewController;
webController2.PacketId = id;
webController2.navigationContoller = nav;
nav.PushViewController(webController2, true);
}
上部代碼工作正常打開特定的ViewController。
但我的應用程序崩潰之後崩潰日誌。
崩潰報告:
2017-07-26 15:25:18.330 Aastha.iOS[6357:2021514] nested push animation can result in corrupted navigation bar
2017-07-26 15:25:18.740 Aastha.iOS[6357:2021514] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
我的解決方案:
,當我在谷歌搜索,所以有人說,打開視圖控制器陸續從各個視圖控制器ViewDidAppear
方法,但我不知道如果這是正確的方式。
任何幫助被讚賞。
嘗試在某種延遲後推送所有控制器。它可能不會使應用程序崩潰。 – Nirmalsinh
發佈了一個答案,但刪除了它(沒有注意到它是爲xamarin)。話雖如此......'UINavigationController'包括一個方法來建立多個控制器作爲孩子('func setViewControllers(_ viewControllers:[UIViewController],animated:Bool)')。我對xamarin一無所知,但也許這種方法橋接在那裏(?) – Alladinian
剛剛檢查了Xamarin的文檔...方法[肯定存在](https://developer.xamarin.com/api/member/UIKit.UINavigationController .SetViewControllers/p/UIKit.UIViewController []/System.Boolean /)。所以你需要像'nav.SetViewControllers([controllers],true)' – Alladinian