简体   繁体   English

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

[英]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它就像魔术一样,谢谢你们

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

相关问题 单击选项卡栏控制器时,应用程序崩溃 - App Crashes when I click Tab Bar Controller 当我在搜索栏中键入内容时,我的应用崩溃 - when i type in search bar my app crashes 当我返回菜单时,应用程序崩溃(线程 1:信号 SIGABRT) - When I go back to menu, the App crashes (Thread 1: signal SIGABRT) 当我单击 Google 登录按钮时,iOS 应用程序崩溃 - iOS app crashes when I click Google Sign-In button 每次我点击搜索栏时ios应用程序崩溃,同时从parse.com撤消数据 - ios app crashes each time i click on the search bar, while retreving data from parse.com 当我单击导航栏时,我的应用将转到以前的视图 - When I click on navigation bar, my app goes to previous view 侧面导航栏(菜单)(iOS 6),如Facebook应用程序+故事板 - Side navigation bar (menu) (iOS 6) like in Facebook app + storyboards 从侧边菜单单击时,导航栏未填充在状态栏下? - Navigationbar not filling under status bar when clicked from side menu? 当提供自定义侧面菜单时,如何隐藏状态栏的一部分 - How to hide part of status bar, when custom side menu presented UIButton单击使应用程序崩溃 - UIButton click crashes app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM