Skip to content

Instantly share code, notes, and snippets.

@hhartz
Created February 23, 2016 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hhartz/3c5356919e8962b3f6be to your computer and use it in GitHub Desktop.
Save hhartz/3c5356919e8962b3f6be to your computer and use it in GitHub Desktop.
@import WebKit;
#import "ViewController.h"
@interface ViewController () <WKNavigationDelegate>
@end
@implementation ViewController
{
WKWebView *_webView;
}
- (void)viewDidLoad {
[super viewDidLoad];
WKWebViewConfiguration *webConfiguration = [self getConfiguration];
_webView = [[WKWebView alloc] initWithFrame:UIEdgeInsetsInsetRect(self.view.bounds, UIEdgeInsetsMake(20, 0, 0, 0)) configuration:webConfiguration];
_webView.navigationDelegate = self;
_webView.translatesAutoresizingMaskIntoConstraints = YES;
_webView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self.view addSubview:_webView];
}
- (WKWebViewConfiguration *)getConfiguration
{
WKWebViewConfiguration *webConfiguration = [[WKWebViewConfiguration alloc] init];
WKUserContentController *userContentController = [[WKUserContentController alloc] init];
webConfiguration.userContentController = userContentController;
return webConfiguration;
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
[_webView loadHTMLString:@"<HTML><BODY>hello webkit</BODY></HTML>" baseURL:nil];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment