アプリでを使用してUIWebView
います。通常は問題なく動作しますが、アプリがメモリ警告を受け取り、最終的にクラッシュする状況があります。
これでコンテンツをロードします:
[self.webView loadHTMLString:htmlString baseURL:baseURL];
25 以上の YouTube ビデオが含まれているケースが 1 つありますhtmlString
(これは私の考えではありません。これは私が受信している Web ページです)。したがって、この場合、アプリはいくつかのメモリ警告を受け取り、最終的にクラッシュします。
どうすればこの状況を管理できますか? さまざまな手順で HTML ファイルを読み込むことはできますか?
これが関係しているかどうかはわかりませんが、UIWebView
サイズ (および Web ビューを囲むスクロール ビューのコンテンツ サイズ) を動的に設定しています。これはコードです:
- (void) webViewDidFinishLoad:(UIWebView *)webView
{
// Adaptamos las vistas al contenido y ocultamos el indicador de actividad
// Ponemos el webView del tamaño justo del contenido
CGRect frame = webView.frame;
// Hace falta cambiar la height porque si no, no coge los cambios. Visualmente no se ve diferencia
frame.size.height = 1;
webView.frame = frame;
CGSize fittingSize = [webView sizeThatFits:CGSizeZero];
frame.size.height = fittingSize.height;
webView.frame = frame;
// Movemos el botón y lo ponemos donde acabe el webView
CGRect buttonFrame = self.visitSiteButton.frame;
buttonFrame.origin.y = frame.origin.y + frame.size.height + 20;
self.visitSiteButton.frame = buttonFrame;
// Ampliamos el contenSize del scrollview general para que quepa todo el webView
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width, self.visitSiteButton.frame.origin.y + self.visitSiteButton.frame.size.height + 10);
}
どうもありがとう、
カルロス