I have created a web view on a plane in SceneKit like so:
self.webView = ARWebView(frame: CGRect(x: 0, y: 0, width: 500, height: 500))
self.material_webPlane.diffuse.contents = self.webView
let geom_webPlane = SCNPlane(width: 0.2, height: 0.2)
geom_webPlane.materials = [material_webPlane]
ARWebView is a subclass of UIWebView simply to override the canBecomeFirstResponder method (in an attempt to solve the issue to no avail):
class ARWebView: UIWebView {
override var canBecomeFirstResponder: Bool {
return true
}
}
Everything works well up until the user touches on a text input field in the web view e.g in the search bar on google.com. The web view effectively focuses on the search bar as it should, the input cursor appears in the search bar but no keyboard appears on screen to be able to input text.
I have also run the following loop to check the Window hierarchy
for window: UIWindow in UIApplication.shared.windows {
print("isKeyWindow:\(window.isKeyWindow) windowLevel:\(window.windowLevel) frame:\(NSStringFromCGRect(window.frame)) class:\(type(of: window).description())")
}
which produces the following result:
isKeyWindow:true windowLevel:0.0 frame:{{0, 0}, {1366, 1024}} class:UIWindow
isKeyWindow:false windowLevel:0.0 frame:{{0, 0}, {1366, 1024}} class:UIWindow
isKeyWindow:false windowLevel:10.0 frame:{{0, 0}, {1366, 1024}} class:UITextEffectsWindow
isKeyWindow:false windowLevel:10000.0 frame:{{0, 0}, {500, 500}} class:_SCNSnapshotWindow
This is all in an ARSCNView which is essentially a SCNScene with a live camera backing on the actual iPhone/iPad device iOS11. I'm more concerned about the webview receiving input than actually seeing the keyboard view (i.e even if the user has to use a wireless keyboard).
Looks like the UIWebView just plain refuses to become the first resonder. Looking deeper it would seem that when a UIWebView *does* become the first resonder in a more normal setup, it's actually the private sub-sub view UIWebBrowserView that in fact becomes the first responder:
UIWebView
> UIScrollView
> UIWebBrowserView
Which means there's no touching that without probable app-rejection.
Well, my conclusion so far is that my UIWebView is a child of the _SCNSnapshotWindow which looks to me like Apple's means of rendering a view hierarchy onto scenekit geometry. It will probably have to pre-compose this hierarchy in the form of an arbitrary window, the _SCNSnapshotWindow then map that onto the geometry. The upshot is it seems, the _SCNSnapshotWindow can't become the *key* window which means it can't function in the responder chain.
Please, does anyone know how I can get the webview to start receiving inputs/how to get the keyboard to show up correctly? What am I doing wrong?