popToViewController 后 pushViewController 上的应用程序崩溃
App crash on pushViewController after popToViewController
我试图搜索这个,但找不到任何完美的解决方案。
我的应用程序有自定义动画视图,两侧 drawers.I 也有自定义导航控制器,它有滑动顶部 bar.From appDelegate 我将第一个控制器设置为 rootViewController 然后推送 ViewController(即 mainViewController 和动画)。
然后试图推动第二个控制器。我可以从第二个控制器转到第三个控制器或单击按钮时的 rootViewController。
当我使用 popToViewController.
从 secondController 返回后尝试转到第二个 viewController 时,应用程序崩溃了
我在 appdelegate 中将 rootViewController 设置为:
let profileViewController = mainStoryboard.instantiateViewController(withIdentifier: "LoadingDataView") as! LoadingDataView
self.navigationController = SDNavigationController(rootViewController: profileViewController);
self.navigationController.navigationBar.isHidden=true;
self.window!.rootViewController = self.navigationController
self.window!.makeKeyAndVisible()
将 ViewController(mainController) 推送为:
if( app.navigationController.viewControllers.count < 2){
let profileViewController=mainStoryboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
app.navigationController?.pushViewController(profileViewController, animated: true);
}else{
let profileViewController=mainStoryboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
app.navigationController?.pushViewController(profileViewController, animated: false);
let emptyView = UIViewController();
app.navigationController?.pushViewController(emptyView, animated: false);
app.navigationController.popViewController(animated: true);
}
然后将第二个 viewController 推为:
let tutorialView=myStory.instantiateViewController(withIdentifier: "BookmarksDetails") as! BookmarksDetails;
self.navigationController!.pushViewController(tutorialView, animated: true);
从第二个 viewController 回来:
let testController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ViewController") as! ViewController
let appDelegate = UIApplication.shared.delegate as! AppDelegate
testController.isOpenLeftDrawer = true
appDelegate.window?.rootViewController = testController
self.navigationController?.popToRootViewController(animated: true)
当我尝试从 viewController(mainController) 转到第二个 ViewController 时,应用程序崩溃了。
你为什么要这样做 -
app.navigationController.popViewController(animated: true);
这里只push,不使用popViewController代码
我试图搜索这个,但找不到任何完美的解决方案。 我的应用程序有自定义动画视图,两侧 drawers.I 也有自定义导航控制器,它有滑动顶部 bar.From appDelegate 我将第一个控制器设置为 rootViewController 然后推送 ViewController(即 mainViewController 和动画)。 然后试图推动第二个控制器。我可以从第二个控制器转到第三个控制器或单击按钮时的 rootViewController。 当我使用 popToViewController.
从 secondController 返回后尝试转到第二个 viewController 时,应用程序崩溃了我在 appdelegate 中将 rootViewController 设置为:
let profileViewController = mainStoryboard.instantiateViewController(withIdentifier: "LoadingDataView") as! LoadingDataView
self.navigationController = SDNavigationController(rootViewController: profileViewController);
self.navigationController.navigationBar.isHidden=true;
self.window!.rootViewController = self.navigationController
self.window!.makeKeyAndVisible()
将 ViewController(mainController) 推送为:
if( app.navigationController.viewControllers.count < 2){
let profileViewController=mainStoryboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
app.navigationController?.pushViewController(profileViewController, animated: true);
}else{
let profileViewController=mainStoryboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
app.navigationController?.pushViewController(profileViewController, animated: false);
let emptyView = UIViewController();
app.navigationController?.pushViewController(emptyView, animated: false);
app.navigationController.popViewController(animated: true);
}
然后将第二个 viewController 推为:
let tutorialView=myStory.instantiateViewController(withIdentifier: "BookmarksDetails") as! BookmarksDetails;
self.navigationController!.pushViewController(tutorialView, animated: true);
从第二个 viewController 回来:
let testController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ViewController") as! ViewController
let appDelegate = UIApplication.shared.delegate as! AppDelegate
testController.isOpenLeftDrawer = true
appDelegate.window?.rootViewController = testController
self.navigationController?.popToRootViewController(animated: true)
当我尝试从 viewController(mainController) 转到第二个 ViewController 时,应用程序崩溃了。
你为什么要这样做 -
app.navigationController.popViewController(animated: true);
这里只push,不使用popViewController代码