私はウェブビューの背景に画像を表示しようとしていますが、内側に青色の長方形と質問マークがあります。私のコードはウェブビューで画像を表示する
NSString *myDescriptionHTML = [NSString stringWithFormat:@"<html> \n"
"<head> \n"
"<style type=\"text/css\"> \n"
"body {font-family:helvetica; font-size:12;}\n"
"h2 {font-family:Times new roman;color: #105870}"
"</style> \n"
"</head> \n"
"<body><img src=\"background.png\" /><h2>Nom station</h2>%@<h2>Adresse</h2>%@<h2>Tél</h2>%@<h2>Sens de circulation</h2>%@<h2>Voie</h2>%@<h2>Station de lavage</h2>%@<h2>Commerce</h2>%@<h2>Distance</h2>%@<h2>Types de carburants</h2>%@</body>\n"
"</html>",leNomDeLaStation,adresseDeLaStation,telDeLaStation,circulationDeLaStation,voieDeLaStation,lavageDeLaStation,commerceDeLaStation,distanceDeLaStation,typesDeCarburantsDeLaStation];
[webView loadHTMLString:myDescriptionHTML baseURL:nil];
background.png
以外のすべてのテキストが正しく表示されます。助けをありがとう:)
EDIT: 私はこれを試してみました:
NSString* basePath = [[NSBundle mainBundle] bundlePath];
NSURL *url = [NSURL URLWithString:basePath];
NSString *myDescriptionHTML = [NSString stringWithFormat:@"<html> \n"
"<head> \n"
"<style type=\"text/css\"> \n"
"body {font-family:helvetica; font-size:12;}\n"
"h2 {font-family:Times new roman;color: #105870}"
"</style> \n"
"</head> \n"
"<body><img src=\"background.png\" /><h2>Nom station</h2>%@<h2>Adresse</h2>%@<h2>Tél</h2>%@<h2>Sens de circulation</h2>%@<h2>Voie</h2>%@<h2>Station de lavage</h2>%@<h2>Commerce</h2>%@<h2>Distance</h2>%@<h2>Types de carburants</h2>%@</body>\n"
"</html>",leNomDeLaStation,adresseDeLaStation,telDeLaStation,circulationDeLaStation,voieDeLaStation,lavageDeLaStation,commerceDeLaStation,distanceDeLaStation,typesDeCarburantsDeLaStation];
[webView loadHTMLString:myDescriptionHTML baseURL:url];
はいつも私が尋問マークを得た:(
:私のコードはそれで問題を抱えているいずれかのために、このです
fileURLWithPath:path
方法を。 :) – Kjuly