互动广告IOS代码接入范例

// WKWebView基本设置
- (void)configureWKWebview{

    WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
    // 设置偏好设置
    config.preferences = [[WKPreferences alloc] init];
    // 默认为0
    config.preferences.minimumFontSize = 10;
    // 默认认为YES
    config.preferences.javaScriptEnabled = YES;
    // 在iOS上默认为NO,表示不能自动通过窗口打开
    config.preferences.javaScriptCanOpenWindowsAutomatically = YES;
    //     web内容处理池
    config.processPool = [[WKProcessPool alloc] init];

    _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - (44 + ([[UIApplication sharedApplication] statusBarFrame].size.height))) configuration:config];

    [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.productIosUrl] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:5.0]];

    _webView.configuration.allowsInlineMediaPlayback = YES;
    _webView.configuration.requiresUserActionForMediaPlayback = NO;

    [self.view addSubview:_webView];

}

results matching ""

    No results matching ""