繁体   English   中英

单击侧栏菜单时应用程序崩溃

[英]App crashes when I click on side bar menu

在它工作之前,当我更新 iOS 13 并将 xCode 更新为 11 时,我无法使用侧栏。 该应用程序正在使用 pod SideMenuController,当我单击侧面菜单的图标以显示它时,它崩溃并显示以下消息:


Assertion failure in -[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3899.22.15/UIApplication.m:5311

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.'

以前的代码:

UIApplication.shared.statusBarView?.backgroundColor = UIColor.init(red: 243/250, green: 243/250, blue: 243/250, alpha: 1)

改成:

我以前遇到过这个问题。 当我使用 XCode 11 和 Swift 5.0 运行此代码时,我的应用程序崩溃了:

if #available(iOS 13.0, *) {

    let statusBar = UIView(frame: UIApplication.shared.keyWindow?.windowScene?.statusBarManager?.statusBarFrame ?? CGRect.zero)

     statusBar.backgroundColor = UIColor.init(red: 243/250, green: 243/250, blue: 243/250, alpha: 1)

     UIApplication.shared.keyWindow?.addSubview(statusBar)

} else {

     UIApplication.shared.statusBarView?.backgroundColor = UIColor.init(red: 243/250, green: 243/250, blue: 243/250, alpha: 1)

}

我会回答为什么我不显示代码,因为我没有做到,在我之前的工程师用一个名为 SideMenuController 的 pod 做到了。 所以我对项目或里面的代码不熟悉。 我做了很多研究并修复了它,我想与您分享解决方案。 (PS:我不知道它是如何工作的)在 pod 的描述中,我需要评论这一行:

 SideMenuController.preferences.animating.transitionAnimator = FadeAnimator.self 

和另一行改变:

SideMenuController.preferences.animating.statusBarBehaviour = .horizontalPan

到这一行:

  SideMenuController.preferences.animating.statusBarBehaviour = .showUnderlay

它就像魔术一样,谢谢你们

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM