开发者

pulling info from a plist

开发者 https://www.devze.com 2023-01-09 11:55 出处:网络
I\'m able to pull information from a plist using: nameTextFi开发者_如何学编程eld.text = [recipe objectForKey:NAME_KEY];

I'm able to pull information from a plist using:

nameTextFi开发者_如何学编程eld.text = [recipe objectForKey:NAME_KEY];
ingredientsText.text = [ingredients objectForKey:NAME_KEY];

I also have images in the plist [the names of the images, not the image data]

does anyone know how i would display an image in a similar manner?

thanks in advance.


You'll have to create an image with the contents of the file at the stored path. Either use imageWithContentsOfFile: or imageNamed:, where imageNamed: takes only the filename and caches images, useful for images that are small and appear often in the UI. Also note, that imageNamed: searches for a @2x-Version of the image in iOS4.

imageWithContentsOfFile takes a full path including your app-bundle's path and dose not have a cache. It's intended for larger images that only appear once on a screen.

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

精彩评论

暂无评论...
验证码 换一张
取 消