是否有一种特殊的方式来布局WKWebView?

时间:2018-04-14 09:18:50

标签: ios swift wkwebview

我遇到了像WKWebView这样的问题

    let configuration = WKWebViewConfiguration()
        configuration.applicationNameForUserAgent = "Browser"
        configuration.ignoresViewportScaleLimits = true
        configuration.allowsInlineMediaPlayback = true
        configuration.allowsAirPlayForMediaPlayback = true
        configuration.allowsPictureInPictureMediaPlayback = true
        configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypes.audio
        configuration.selectionGranularity = WKSelectionGranularity.character
        configuration.dataDetectorTypes = WKDataDetectorTypes.link
    let webview = WKWebView(frame: .zero, configuration: configuration)
        webview.allowsBackForwardNavigationGestures = true
        webview.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        webview.uiDelegate = self
        webview.navigationDelegate = self
    let url = URL(string: "https://www.google.com")!
    let request = URLRequest(url: url)
        webview.load(request)
        self.view = webview

每当我在网站上输入搜索框,例如“Google”时,我会在调试器中输入此日志...我似乎无法理解为什么在我没有设置任何内容时它会引发约束问题...和此视图包含在具有UINavigationController

UIToolbar

Picture 1/2 Picture 2/2

故事板的截图。

Container View

0 个答案:

没有答案