简体   繁体   English

如何在直接来自Web服务解析的UIscrollView中显示图像?

[英]how can i display image in UIscrollView which comes directly from parsing of web service?

我想在UIScrollView上的UIImageView中显示图像,并使用Touch Event将该图像也从右到左和从左到右更改。图像是NSXml解析的结果,所以我该怎么办请帮助我在这个任务中。我应该怎么做,如果可能的话,再给我看一些例子。谢谢前进.....

Depends on how you obtain the images. 取决于您如何获取图像。

If you get them as URLs, you need to download the actual images. 如果将它们作为URL获得,则需要下载实际图像。 There are examples of doing this. 有这样做的例子。

If you get them as NSData (from downloading them or such), you just have to init a UIImage with the data, eg [UIImage imageWithData:] or [[UIImage alloc] initWithData:] . 如果以NSData的形式获取它们(通过下载等),则只需使用数据初始化UIImage,例如[UIImage imageWithData:][[UIImage alloc] initWithData:]

Then you just do what everyone else does when adding an image to a scroll view. 然后,您只需执行将图像添加到滚动视图中时其他所有人的工作即可。 There are hundreds of examples. 有数百个示例。 In short, add the image to a UIImageView then add that view to the scroll view using addSubview: . 简而言之,将图像添加到UIImageView然后使用addSubview:将该视图添加到滚动视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM