Skip to content

Commit

Permalink
Adds hack to fix issue with webview and the use of network.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Guido Marucci Blas committed Dec 31, 2014
1 parent 2c7c2b3 commit a817b8c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Pod/Classes/WLXWebViewReloader.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit a817b8c

Please sign in to comment.