我正在开发一个 iOS 应用程序,它将在 wkWebView 中显示一些 360 度全景内容。该页面确实会加载,但当它收到内存警告时,它会在 iPad 2 上显示空白视图。
相关代码:
NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://360yerevan.com/mobilembed/91001/"] ];
NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);";
WKUserScript *wkUScript = [[WKUserScript alloc] initWithSource:jScript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
WKUserContentController *wkUController = [[WKUserContentController alloc] init];
[wkUController addUserScript:wkUScript];
WKWebViewConfiguration *wkWebConfig = [[WKWebViewConfiguration alloc] init];
wkWebConfig.userContentController = wkUController;
wkWebConfig.processPool = [[WKProcessPool alloc] init];
WKWebView *webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:wkWebConfig];
[self.view addSubview:webView];
[webView loadRequest:req];
这在 iPhone 5/5S 上运行良好。
有什么想法吗?