Heim  >  Fragen und Antworten  >  Hauptteil

Die Statusleiste von Capacitor und JS überschneidet sich in IOS

Ich verwende NuxtJS mit Kondensator. Die obere Statusleiste auf iOS-Geräten überschneidet sich beim Scrollen. Ich habe auch "ios": {"contentInset": "always"} in Capacitor.config.json hinzugefügt.

Obwohl ich auch CSS eingebunden habe, schafft es oben zusätzlichen Platz.

body {
   padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
     env(safe-area-inset-left);
 }

P粉543344381P粉543344381295 Tage vor411

Antworte allen(1)Ich werde antworten

  • P粉198670603

    P粉1986706032023-12-30 13:19:52

    这可以通过在 CAPViewBridgeController 文件中添加以下行来实现

    webView?.frame.origin = CGPoint(x: 0, y: UIApplication.shared.statusBarFrame.size.height)
    
    webView?.frame.size.height = UIScreen.main.bounds.size.height - UIApplication.shared.statusBarFrame.size.height;

    搜索以下功能并更新。该函数应该如下所示

    extension CAPBridgeViewController: CAPBridgeDelegate {
        internal var bridgedWebView: WKWebView? {
            webView?.frame.origin = CGPoint(x: 0, y: UIApplication.shared.statusBarFrame.size.height)
            webView?.frame.size.height = UIScreen.main.bounds.size.height - UIApplication.shared.statusBarFrame.size.height;
            return webView
        }
    
        internal var bridgedViewController: UIViewController? {
            return self
        }
    }

    Antwort
    0
  • StornierenAntwort