WebView に問題があります。Html 文字列を Web ビューに読み込んでいます。ベース URL として、自分のサイト URL を使用する必要があります (html 内に相対リンクがあり、変更できないため)。問題は、アプリケーション バンドル内に格納されているいくつかの画像と css も使用する必要があることです。したがって、このコードを使用してローカル リソースへの参照を作成しています (結果の文字列は html ファイルで src として使用されます)。
NSString *cssUrl = [NSString stringWithString:@"file:"];
cssUrl = [cssUrl stringByAppendingString:[[NSBundle mainBundle] resourcePath]];
cssUrl = [cssUrl stringByAppendingString:@"/story.css"];
それから私も追加しました:
cssUrl = [cssUrl stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
cssUrl = [cssUrl stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
問題を解決する方法と、Web ビュー内で使用できるファイルへの参照を作成する方法はありますか? ありがとう
フランチェスコ