Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.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/3/sockets/2.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
Iphone 从plist中提取信息_Iphone_Plist - Fatal编程技术网

Iphone 从plist中提取信息

Iphone 从plist中提取信息,iphone,plist,Iphone,Plist,我能够通过以下方式从plist中提取信息: nameTextField.text = [recipe objectForKey:NAME_KEY]; ingredientsText.text = [ingredients objectForKey:NAME_KEY]; 我在plist中也有图像[图像的名称,而不是图像数据] 有人知道我如何以类似的方式显示图像吗 提前感谢。您必须在存储路径中创建包含文件内容的图像。使用imageWithContentsOfFile:或imageNamed:,其中

我能够通过以下方式从plist中提取信息:

nameTextField.text = [recipe objectForKey:NAME_KEY];
ingredientsText.text = [ingredients objectForKey:NAME_KEY];
我在plist中也有图像[图像的名称,而不是图像数据]

有人知道我如何以类似的方式显示图像吗


提前感谢。

您必须在存储路径中创建包含文件内容的图像。使用
imageWithContentsOfFile:
imageNamed:
,其中
imageNamed:
仅获取文件名并缓存图像,这对于较小且经常出现在UI中的图像非常有用。还要注意,
imageNamed:
在iOS4中搜索@2x版本的图像

imageWithContentsOfFile
采用包含应用程序包路径的完整路径,并且没有缓存。它适用于屏幕上只出现一次的较大图像

imageView.image = [UIImage imageNamed:[recipe objectForKey:IMAGE_KEY]];
imageView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] 
                           pathForResource:[recipe objectForKey:IMAGE_KEY] ofType:nil]];