某些图片无法传递给 imageview.image,为什么?
Some images cannot be passed to imageview.image, why?
将 xml 数据从 table 视图解析为详细视图,我将数据传递给 imageview.image
。有些图像显示在视图中,有些不显示。
当我调试时,imageview.image
有时是 nil
,有时是图像对象。
imageview.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:sharedDelegate.imagObj]]];
这是viewdidload
中的代码。
在link中都是jpg文件而已。
对于dataWithContentsOfURL
官方documentation声音:
This method is ideal for converting data:// URLs to NSData objects, and can also be used for reading short files synchronously. If you need to read potentially large files, use inputStreamWithURL: to open a stream, then read the file a piece at a time.
将 xml 数据从 table 视图解析为详细视图,我将数据传递给 imageview.image
。有些图像显示在视图中,有些不显示。
当我调试时,imageview.image
有时是 nil
,有时是图像对象。
imageview.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:sharedDelegate.imagObj]]];
这是viewdidload
中的代码。
在link中都是jpg文件而已。
对于dataWithContentsOfURL
官方documentation声音:
This method is ideal for converting data:// URLs to NSData objects, and can also be used for reading short files synchronously. If you need to read potentially large files, use inputStreamWithURL: to open a stream, then read the file a piece at a time.