Retry the webkit load until we've connected to the server.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4542 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
1e5aa0ba93
commit
8c4ec71e26
27
src/ios.m
27
src/ios.m
@ -1,6 +1,5 @@
|
||||
#include "log.h"
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <WebKit/WKNavigationDelegate.h>
|
||||
#import <WebKit/WKUIDelegate.h>
|
||||
#import <WebKit/WKWebView.h>
|
||||
#import <WebKit/WKWebViewConfiguration.h>
|
||||
@ -10,10 +9,16 @@
|
||||
|
||||
void tf_run_thread_start(const char* zip_path);
|
||||
|
||||
@interface ViewController : UIViewController<WKUIDelegate>
|
||||
@interface ViewController : UIViewController<WKUIDelegate,WKNavigationDelegate>
|
||||
@property(strong, nonatomic) WKWebView* web_view;
|
||||
@property bool initial_load_complete;
|
||||
@end
|
||||
|
||||
static void _start_initial_load(WKWebView* web_view)
|
||||
{
|
||||
[web_view loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost:12345/"]]];
|
||||
}
|
||||
|
||||
@implementation ViewController : UIViewController
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
@ -21,8 +26,22 @@ void tf_run_thread_start(const char* zip_path);
|
||||
WKWebViewConfiguration* configuration = [[WKWebViewConfiguration alloc] init];
|
||||
self.web_view = [[WKWebView alloc] initWithFrame:self.view.frame configuration:configuration];
|
||||
self.web_view.UIDelegate = self;
|
||||
[self.web_view loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost:12345/"]]];
|
||||
self.web_view.navigationDelegate = self;
|
||||
[self.view addSubview:self.web_view];
|
||||
_start_initial_load(self.web_view);
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
|
||||
{
|
||||
self.initial_load_complete = true;
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
|
||||
{
|
||||
if (!self.initial_load_complete)
|
||||
{
|
||||
_start_initial_load(self.web_view);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler
|
||||
|
Loading…
Reference in New Issue
Block a user