【问题标题】:How to fix "RCTStatusBarManager module requires that the UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO"如何修复“RCTStatusBarManager 模块要求 Info.plist 中的 UIViewControllerBasedStatusBarAppearance 键设置为 NO”
【发布时间】:2021-03-05 08:26:08
【问题描述】:

在我的应用中,我使用 React Native(遗留代码)和 iOS 原生组件。

最近我在我的 iOS ViewController 中实现了preferredStatusBarStyle 覆盖。

但是 preferredStatusBarStyle 在 Info.plist 中没有 View controller-based status bar appearance = YES 就无法工作。所以我把这个键改成了YES。

现在我有一个 React Native 错误:“RCTStatusBarManager 模块要求 Info.plist 中的 UIViewControllerBasedStatusBarAppearance 键设置为 NO”

Error screenshot.

有什么方法可以在不更改 .plist 的情况下消除错误?我搜索了所有遗留的 React 代码,没有发现 StatusBar React 组件的任何用途

【问题讨论】:

    标签: ios react-native


    【解决方案1】:

    由于 React Native 错误,我无法使用现代 preferredStatusBarStyle 解决此问题。但是这种设置状态栏样式的旧方法有所帮助:UIApplication.shared.setStatusBarStyle()

    我写了这个助手来改变我的应用程序中的 statusBar 样式:

    public static func updateStatusBarStyle(isLightBackground: Bool) {
      var statusBarStyle: UIStatusBarStyle
      if isLightBackground, #available(iOS 13.0, *) {
        statusBarStyle = .darkContent
      } else {
        statusBarStyle = isLightBackground ? .default : .lightContent
      }
      UIApplication.shared.setStatusBarStyle(statusBarStyle, animated: true)
    }
    

    【讨论】:

      猜你喜欢
      • 2019-06-15
      • 1970-01-01
      • 2014-04-22
      • 2016-11-27
      • 1970-01-01
      • 2014-02-20
      • 2017-02-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多