我正致力于推送通知。现在当应用程序被提升到设备并且当我点击它时。我想将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);
}
上面的代码可以正常打开Specific 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.
我的解决方案:
当我在google上搜索时,有人说每个ViewController ViewDidAppear
方法一个接一个地打开ViewController,但我不确定这是否正确。
任何帮助都要得到赞赏。
答案 0 :(得分:0)
您无法使用动画推送多个视图控制器。如果您希望用户看到转化A - > B - > C你确实必须在A&B和s的viewDidAppear方法中做到这一点。
如果您希望用户只能看到最后一个视图控制器C并且能够通过A和B返回,您可以一次性推送它们,但是您需要在没有动画的情况下进行操作:
nav.PushViewController(webController2, false);
另一种选择是使用这样的SetViewControllers:
nav.SetViewControllers([A, B, C], true);
这将同时推送所有3个视图控制器,并且只有最顶层的视图控制器将使用推送转换进行动画处理。我不认为这符合你的情况,只是为了完整起见而在这里添加它。