-
-
Save hhartz/3c5356919e8962b3f6be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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