簡體   English   中英

如何在 ios 的 ionic/react v5 中防止“UIColor”沒有成員“systemBackground”和“UIStatusBarStyle”沒有成員“darkContent”?

[英]How to prevent 'UIColor' has no member 'systemBackground' ` and 'UIStatusBarStyle' has no member 'darkContent' in ionic/react v5 for ios?

使用 Ionic react v 5.3.0 編寫一個簡單的應用程序,還沒有插件

After ionic build, Xcode reports swift build error: Type 'UIStatusBarStyle' has no member 'darkContent' ios This happens with swift v 4.2 and swift v 5, ios deployment target 8, 9, 10, and 11

我嘗試按照此處的說明刪除和重新生成node_modulesios目錄: https://ionicframework.com/docs/troubleshooting/native

仍然在 xcode 中看到帶有構建時警告和 4 個 Swift 編譯錯誤的問題。
其中兩個錯誤是Type 'UIColor' has no member 'systemBackground' found in CapBridgeViewcontroller.swift from Pods>Development Pods> Capacitor > Plugins

    if let backgroundColor = (bridge!.config.getValue("ios.backgroundColor") as? String) ?? (bridge!.config.getValue("backgroundColor") as? String) {
      webView?.backgroundColor = UIColor(fromHex: backgroundColor)
      webView?.scrollView.backgroundColor = UIColor(fromHex: backgroundColor)
    } else if #available(iOS 13, *) {
      // Use the system background colors if background is not set by user
      webView?.backgroundColor = UIColor.systemBackground
      webView?.scrollView.backgroundColor = UIColor.systemBackground
    }

另外兩個錯誤是: Type 'UIStatusBarStyle' has no member 'darkContent' found in statusBar.swift

 public func setStatusBarDefaults() {
    if let plist = Bundle.main.infoDictionary {
      if let statusBarHidden = plist["UIStatusBarHidden"] as? Bool {
        if (statusBarHidden) {
          self.isStatusBarVisible = false
        }
      }
      if let statusBarStyle = plist["UIStatusBarStyle"] as? String {
        if (statusBarStyle == "UIStatusBarStyleDarkContent") {
          if #available(iOS 13.0, *) {
            self.statusBarStyle = .darkContent
          } else {
            self.statusBarStyle = .default
          }
        } else if (statusBarStyle != "UIStatusBarStyleDefault") {
          self.statusBarStyle = .lightContent
        }
      }
    }
  }

  @objc func setStyle(_ call: CAPPluginCall) {
    let options = call.options!

    if let style = options["style"] as? String {
      if style == "DARK" {
        bridge.setStatusBarStyle(.lightContent)
      } else if style == "LIGHT" {
        if #available(iOS 13.0, *) {
          bridge.setStatusBarStyle(.darkContent)
        } else {
          bridge.setStatusBarStyle(.default)
        }
      }
    }
    
    call.success([:])
  }

我期望的是我可以從 ionic cli 構建我的應用程序,而不必每次構建時都修改 swift 代碼。 我可以在我的 ionic 項目中添加一個設置來防止這個錯誤嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM