Trying to get image source out of plist
in my plist (dictionary entries) i would like to store a path to an image for each item 开发者_Go百科like so:
<key>Image</key>
<string>sit_109_111.jpg</string>
In the app, i would like to set the image source (UIImageView) to that image What do i need to do to convert the value to be able to set it to the uiimageview.image property?
I tried doing this
self.exerciseImage.image=[self.exerciseDetail objectForKey:IMAGE_KEY];
and it crashes
fixed it
self.exerciseImage.image=[UIImage imageNamed:[self.exerciseDetail objectForKey:IMAGE_KEY]];
Assuming you are reading your plist file into a dictionary like so
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
You can do
UIImage *image = [UIImage imageNamed: [plistDict objectForKey:@"Image"]];
[self.exerciseImage setImage:image];
精彩评论