WKWebView is showing only background

末鹿安然 提交于 2019-12-01 08:33:40

问题


I have a simple ARKit app (SceneKit). I create a SCNBox and then I'd like to add a web view on the front side of the cube.

func createBox(position: SCNVector3) {
  let box = SCNBox(width: 0.1, height: 0.1, length: 0.1, chamferRadius: 1)

  guard let url = URL(string: "https://www.google.com") else { return }
  let request = URLRequest(url: url)
  let webView = WKWebView(frame: CGRect(x: 0, y: 0, width: 500, height: 500), configuration: WKWebViewConfiguration())
  webView.load(request)

  let sides = [
    webView,              // Front
    UIColor.black,        // Right
    UIColor.black,        // Back
    UIColor.black,        // Left
    UIColor.black,        // Top
    UIColor.black         // Bottom
  ]

  let materials = sides.map { (side) -> SCNMaterial in
    let material = SCNMaterial()
    material.diffuse.contents = side
    material.locksAmbientWithDiffuse = true
    return material
  }

  box.materials = materials

  let boxNode = SCNNode(geometry: box)
  boxNode.position = position
  sceneView.scene.rootNode.addChildNode(boxNode)
}

It shows only white screen. It's not a blank page. I can scroll it and tap somewhere. And if I open a website with red background, it will be red and so on. It works, but I see only the background (and maybe an elements. For example on https://apple.com I see the background and the grey line on the top (navigation)). How can I solve it? Thanks.

来源:https://stackoverflow.com/questions/47319642/wkwebview-is-showing-only-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!