Html 如何将图像添加到<;p>;并在UIWebView中使用?
如何将图像添加到标签中?在我的html数据中有多个Html 如何将图像添加到<;p>;并在UIWebView中使用?,html,ios,uiwebview,Html,Ios,Uiwebview,如何将图像添加到标签中?在我的html数据中有多个标记。因此,我如何设置要在UIWebView中添加和使用的不同图像。提前感谢您在HTML中添加图像: <p><img src="yourawesomeimage.png" alt="Awesome!" /></p> 要将HTML添加到UIWebView,请执行以下操作: NSString* htmlContent = @"<html><head><title></
标记。因此,我如何设置要在UIWebView中添加和使用的不同图像。提前感谢您在HTML中添加图像:
<p><img src="yourawesomeimage.png" alt="Awesome!" /></p>
要将HTML添加到UIWebView,请执行以下操作:
NSString* htmlContent = @"<html><head><title></title></head><body><p><img src='image.jpg' /></p></body></html>";
[self.webView loadHTMLString:htmlContent baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
NSString*htmlContent=@“”;
[self.webView加载htmlstring:htmlContent baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]bundlePath]];
要在HTML中添加图像:
<p><img src="yourawesomeimage.png" alt="Awesome!" /></p>
要将HTML添加到UIWebView,请执行以下操作:
NSString* htmlContent = @"<html><head><title></title></head><body><p><img src='image.jpg' /></p></body></html>";
[self.webView loadHTMLString:htmlContent baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
NSString*htmlContent=@“”;
[self.webView加载htmlstring:htmlContent baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]bundlePath]];
要在HTML中添加图像:
<p><img src="yourawesomeimage.png" alt="Awesome!" /></p>
要将HTML添加到UIWebView,请执行以下操作:
NSString* htmlContent = @"<html><head><title></title></head><body><p><img src='image.jpg' /></p></body></html>";
[self.webView loadHTMLString:htmlContent baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
NSString*htmlContent=@“”;
[self.webView加载htmlstring:htmlContent baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]bundlePath]];
要在HTML中添加图像:
<p><img src="yourawesomeimage.png" alt="Awesome!" /></p>
要将HTML添加到UIWebView,请执行以下操作:
NSString* htmlContent = @"<html><head><title></title></head><body><p><img src='image.jpg' /></p></body></html>";
[self.webView loadHTMLString:htmlContent baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
NSString*htmlContent=@“”;
[self.webView加载htmlstring:htmlContent baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]bundlePath]];
您可以这样做:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"file:/%@//",imagePath]];
NSString *htmlString = @"<p> <img src=\"sample.jpg\" width=\"50\" height=\"50\"/>";
[webView loadHTMLString:htmlString
baseURL:url];
NSURL*url=[NSURL URLWithString:[NSString stringWithFormat:@“文件:/%@/”,图像路径]];
NSString*htmlString=@“”;
[webView加载htmlString:htmlString
baseURL:url];
您可以这样做:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"file:/%@//",imagePath]];
NSString *htmlString = @"<p> <img src=\"sample.jpg\" width=\"50\" height=\"50\"/>";
[webView loadHTMLString:htmlString
baseURL:url];
NSURL*url=[NSURL URLWithString:[NSString stringWithFormat:@“文件:/%@/”,图像路径]];
NSString*htmlString=@“”;
[webView加载htmlString:htmlString
baseURL:url];
您可以这样做:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"file:/%@//",imagePath]];
NSString *htmlString = @"<p> <img src=\"sample.jpg\" width=\"50\" height=\"50\"/>";
[webView loadHTMLString:htmlString
baseURL:url];
NSURL*url=[NSURL URLWithString:[NSString stringWithFormat:@“文件:/%@/”,图像路径]];
NSString*htmlString=@“”;
[webView加载htmlString:htmlString
baseURL:url];
您可以这样做:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"file:/%@//",imagePath]];
NSString *htmlString = @"<p> <img src=\"sample.jpg\" width=\"50\" height=\"50\"/>";
[webView loadHTMLString:htmlString
baseURL:url];
NSURL*url=[NSURL URLWithString:[NSString stringWithFormat:@“文件:/%@/”,图像路径]];
NSString*htmlString=@“”;
[webView加载htmlString:htmlString
baseURL:url];
- (void)viewDidLoad
{
[super viewDidLoad];
[self redrawDesing];
NSURL *htmlFile = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"legal" ofType:@"html"] isDirectory:NO];
[contentView loadRequest:[NSURLRequest requestWithURL:htmlFile]];
[contentView setScalesPageToFit:YES];
contentView.delegate=self;
[contentView setDelegate:self];
}
-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
if ( inType == UIWebViewNavigationTypeLinkClicked ) {
[[UIApplication sharedApplication] openURL:[inRequest URL]];
return NO;
}
return YES;
}
p、 在本部分中,将“legal”替换为您的html文件名
NSURL*htmlFile=[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@“html”类型的“合法”isDirectory:NO]
- (void)viewDidLoad
{
[super viewDidLoad];
[self redrawDesing];
NSURL *htmlFile = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"legal" ofType:@"html"] isDirectory:NO];
[contentView loadRequest:[NSURLRequest requestWithURL:htmlFile]];
[contentView setScalesPageToFit:YES];
contentView.delegate=self;
[contentView setDelegate:self];
}
-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
if ( inType == UIWebViewNavigationTypeLinkClicked ) {
[[UIApplication sharedApplication] openURL:[inRequest URL]];
return NO;
}
return YES;
}
p、 在本部分中,将“legal”替换为您的html文件名
NSURL*htmlFile=[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@“html”类型的“合法”isDirectory:NO]
- (void)viewDidLoad
{
[super viewDidLoad];
[self redrawDesing];
NSURL *htmlFile = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"legal" ofType:@"html"] isDirectory:NO];
[contentView loadRequest:[NSURLRequest requestWithURL:htmlFile]];
[contentView setScalesPageToFit:YES];
contentView.delegate=self;
[contentView setDelegate:self];
}
-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
if ( inType == UIWebViewNavigationTypeLinkClicked ) {
[[UIApplication sharedApplication] openURL:[inRequest URL]];
return NO;
}
return YES;
}
p、 在本部分中,将“legal”替换为您的html文件名
NSURL*htmlFile=[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@“html”类型的“合法”isDirectory:NO]
- (void)viewDidLoad
{
[super viewDidLoad];
[self redrawDesing];
NSURL *htmlFile = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"legal" ofType:@"html"] isDirectory:NO];
[contentView loadRequest:[NSURLRequest requestWithURL:htmlFile]];
[contentView setScalesPageToFit:YES];
contentView.delegate=self;
[contentView setDelegate:self];
}
-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
if ( inType == UIWebViewNavigationTypeLinkClicked ) {
[[UIApplication sharedApplication] openURL:[inRequest URL]];
return NO;
}
return YES;
}
p、 在本部分中,将“legal”替换为您的html文件名
NSURL*htmlFile=[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@“html”类型的“合法”isDirectory:NO] 小更正:需要在
htmlString中转义“
。@Amar:是的,错过了。小更正:需要在htmlString中转义”
。@Amar:是的,错过了。小更正:需要在htmlString中转义。@Amar:是的,错过了。小更正:需要转义。“
在htmlString
中@Amar:是的,错过了。你能解释一下你的问题吗?你能解释一下你的问题吗?你能解释一下你的问题吗?你能解释一下你的问题吗?