[英]App crashes when I click on side bar menu
Before it worked, when I made the update iOS 13 and updated xCode to 11, I am not able to use the side bar.在它工作之前,当我更新 iOS 13 并将 xCode 更新为 11 时,我无法使用侧栏。 The application is using the pod SideMenuController and when I click on the icon of side menu to show it, it crashes and shows me this message:该应用程序正在使用 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.'
Previous code:以前的代码:
UIApplication.shared.statusBarView?.backgroundColor = UIColor.init(red: 243/250, green: 243/250, blue: 243/250, alpha: 1)
Change to:改成:
I have encountered this issue before.我以前遇到过这个问题。 My application got crash while I run this code using XCode 11 and Swift 5.0.:当我使用 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)
}
I will answer why didn't I show the code, because I didn't made it, the engineer that was before me made it with a pod named SideMenuController.我会回答为什么我不显示代码,因为我没有做到,在我之前的工程师用一个名为 SideMenuController 的 pod 做到了。 So I'm not familiar with the project or the code inside.所以我对项目或里面的代码不熟悉。 I did a lot of research and I fixed it and I wanted to share the solution with you.我做了很多研究并修复了它,我想与您分享解决方案。 ( PS: I don't know how it worked ) in the description of the pod, I needed to comment this line: (PS:我不知道它是如何工作的)在 pod 的描述中,我需要评论这一行:
SideMenuController.preferences.animating.transitionAnimator = FadeAnimator.self
and another line to change from:和另一行改变:
SideMenuController.preferences.animating.statusBarBehaviour = .horizontalPan
To this line:到这一行:
SideMenuController.preferences.animating.statusBarBehaviour = .showUnderlay
And it worked like magic, Thank you guys它就像魔术一样,谢谢你们
Please refer & try:请参考并尝试:
https://github.com/teodorpatras/SideMenuController/issues/174 https://github.com/teodorpatras/SideMenuController/issues/174
merged in a fix for this: https://github.com/cjlarsen/SideMenuController合并为此修复: https://github.com/cjlarsen/SideMenuController
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.