Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何将图像添加到<;p>;并在UIWebView中使用?_Html_Ios_Uiwebview - Fatal编程技术网

Html 如何将图像添加到<;p>;并在UIWebView中使用?

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></

如何将图像添加到标签中?在我的html数据中有多个
标记。因此,我如何设置要在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];
  • 将html文件添加到项目中
  • 将图像放在.html文件旁边
  • 如下所示显示图像:
  • 将viewcontroller添加到项目中
  • 在viewcontroller中,添加UiWebView并将插座链接到头文件
  • 将此代码添加到视图控制器

    - (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]

  • 将html文件添加到项目中
  • 将图像放在.html文件旁边
  • 如下所示显示图像:
  • 将viewcontroller添加到项目中
  • 在viewcontroller中,添加UiWebView并将插座链接到头文件
  • 将此代码添加到视图控制器

    - (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]

  • 将html文件添加到项目中
  • 将图像放在.html文件旁边
  • 如下所示显示图像:
  • 将viewcontroller添加到项目中
  • 在viewcontroller中,添加UiWebView并将插座链接到头文件
  • 将此代码添加到视图控制器

    - (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]

  • 将html文件添加到项目中
  • 将图像放在.html文件旁边
  • 如下所示显示图像:
  • 将viewcontroller添加到项目中
  • 在viewcontroller中,添加UiWebView并将插座链接到头文件
  • 将此代码添加到视图控制器

    - (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:是的,错过了。你能解释一下你的问题吗?你能解释一下你的问题吗?你能解释一下你的问题吗?你能解释一下你的问题吗?