From a817b8c7a5c49226a31f040ec770ff0fa934b1b3 Mon Sep 17 00:00:00 2001 From: Guido Marucci Blas Date: Wed, 31 Dec 2014 17:38:57 -0300 Subject: [PATCH] Adds hack to fix issue with webview and the use of network. WLXWebViewReloader uses an internal WKWebView to load a Javacript code to be able to use SocketIO JS client in order to connect with the watcher server. The problem is that the WKWebView does not perform network requests properly if it is not attached to a view hierarchy. To fix this "issue" I a attached the WLXWebViewReloader's internal webview to the target webview's superview. --- Pod/Classes/WLXWebViewReloader.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Pod/Classes/WLXWebViewReloader.m b/Pod/Classes/WLXWebViewReloader.m index 2043c45..ad2fdc2 100644 --- a/Pod/Classes/WLXWebViewReloader.m +++ b/Pod/Classes/WLXWebViewReloader.m @@ -175,7 +175,15 @@ - (WKWebView *)newSocketIOWebView { return webView; } +- (void)attachSocketIOWebView { + CGRect screenRect = [[UIScreen mainScreen] bounds]; + CGFloat x = - (2 * screenRect.size.width + self.socketIOWebView.frame.size.width); + self.socketIOWebView.frame = CGRectMake(x, 0, self.socketIOWebView.bounds.size.width, self.socketIOWebView.bounds.size.height); + [self.webView.superview addSubview:self.socketIOWebView]; +} + - (void)loadSocketIOWebView { + [self attachSocketIOWebView]; NSURLRequest * request = [NSURLRequest requestWithURL:self.socketIOWebViewURL]; [self.socketIOWebView loadRequest:request]; }