Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.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
Ios uiwebview未从xml加载图像_Ios_Iphone_Objective C_Xml_Uiwebview - Fatal编程技术网

Ios uiwebview未从xml加载图像

Ios uiwebview未从xml加载图像,ios,iphone,objective-c,xml,uiwebview,Ios,Iphone,Objective C,Xml,Uiwebview,我有一些我不知道如何解决的问题,我希望有人能帮助我 我有MasterViewController,他正在显示来自xml的新闻,DetailViewController在MVC中显示来自所选主题的详细信息,并在UIWebView中显示。第一个问题是图像不是从UIWebView中的xml加载的,第二个问题是如何使文本下面的链接在我按下它时显示在另一个UIWebView中 我的代码是: - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:

我有一些我不知道如何解决的问题,我希望有人能帮助我

我有MasterViewController,他正在显示来自xml的新闻,DetailViewController在MVC中显示来自所选主题的详细信息,并在UIWebView中显示。第一个问题是图像不是从UIWebView中的xml加载的,第二个问题是如何使文本下面的链接在我按下它时显示在另一个UIWebView中

我的代码是:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"showDetail"]) {

    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    NSString *string = [feeds[indexPath.row] objectForKey: @"description"];
    NSString *htmlStrippedString = [string stringByReplacingOccurrencesOfString:@"</?[a-z]+>" withString:@"" options:NSRegularExpressionSearch | NSCaseInsensitiveSearch range:NSMakeRange(0, [string length])];
    htmlStrippedString = [htmlStrippedString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    DetailViewController *dvc = [segue destinationViewController];
    dvc.myString = htmlStrippedString;
  }
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    [webView loadHTMLString:myString baseURL:nil];
}

谢谢。

您的img src文件正在调用

/s/c/images.24ur.com/media/images/210/mar2013/80x80/61180414.jpg
这在UIWebView中没有任何意义。像这样的相对链接取决于浏览器对服务器进行预处理的能力,但UIWebView并没有那么智能。你需要预先准备一个http://whatever.server.the.image.lives.at.com 发送到src,以便web视图请求有效的URL:

http://whatever.server.the.image.lives.at.com/s/c/images.24ur.com/media/images/210/mar2013/80x80/61180414.jpg

您的web视图没有图像的正确路径,因为标记中的src=错误:

src=/s/c/images.24ur.com/media/images/210/mar2013/80x80/61180414.jpg

您需要更改图像路径显示为HTML的方式。具体来说,您需要为HTML页面提供正确的路径,以便它可以提取图像。例如,类似这样的内容:

src=HTTP://YOURSITE.COM/s/c/images.24ur.COM/media/images/210/mar2013/80x80/61180414.jpg


我希望这有帮助

xml中图像的URL是什么?这是我的一个xml问题,这是我从xml中得到的,但谢谢你们,我会尝试你们的建议。没问题。您可能需要单独拉取这个XML节点,将URL添加到字符串中并将其存储为变量。例如,在PHP中:$xml\u url=$xml\u object->url;然后将URL添加到变量的开头:$xml_URL=;我希望这有帮助!是的,穆瑟,这正是我所需要的,但我没有太多的知识在Obj.c中做到这一点。我用谷歌搜索了一下,但运气不好。有关于这个主题的教程吗?谢谢你们帮助大家。