Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

spinedoc77

macrumors G4
Original poster
Jun 11, 2009
11,488
5,414
I currently have a project which includes a table of items, clicking on a row for a particular item will bring you to a detail view which includes description text for the item. I'm currently pulling the items from a plist (dictionary array).

I'd like to also add an image into the detailed view but am not sure how to go about it. This is how I am currently calling the items in my detailed view.

Code:
-(void) viewWillAppear: (BOOL)animated {
    [super viewWillAppear:animated];
    //set up UI with muscle names
    self.textField.text=[self.muscleNames objectForKey: NAME_KEY];
    self.textView.text=[self.muscleNames objectForKey: DESCRIPTION_KEY];
}

I know images cannot be stored in the plist itself, but can I put in a pointer to the image file, which would be in the supporting files? I can set up UIImageView and link it up, but I'm not sure how to implement it.
 
Last edited by a moderator:
The simplest thing to do is simply put the image file name in the plist and use that to create the UIImage to display in the view.
 
The simplest thing to do is simply put the image file name in the plist and use that to create the UIImage to display in the view.

I've gotten this far, I'm just not sure how to call the image up in my method above. I've tried, for example,

Code:
self.imageView.image=[self.muscleNames objectForKey: IMAGE_KEY];

This is linked with a UIIMageView element dragged in from IB in the detailed view.
 
Last edited by a moderator:
What is muscleImages? How is it setup/declared?

muscleNames is a my plist dictionary, it works to display the name and description of what I am referencing.

Code:
@interface DetailedView : UIViewController {
@private
    
    IBOutlet UITextView *textView_;
    IBOutlet UITextField *textField_;
    IBOutlet UIImageView *imageView_;
    NSDictionary *muscleNames_;
}

@property (nonatomic, retain) IBOutlet UITextView *textView;
@property (nonatomic, retain) IBOutlet UITextField *textField;
@property (nonatomic, retain) NSDictionary *muscleNames;
@property (nonatomic, retain) IBOutlet UIImageView *imageView;

@end[COLOR="#808080"]

----------

[/COLOR]self.imageView.[B][COLOR="Red"]image[/COLOR][/B]=[self.muscleNames objectForKey: IMAGE_KEY];

This is where I think I'm doing something wrong, I'm used to calling text.
 
That does not answer the question. How is muscleNames setup. Where do you assign a value to it and populate the array?

If it is a dictionary loaded from a plist what makes you think you can do what you are trying to do? The value assiged to self.imageview.image must be a UIImage. You are not assigning a UIImage. Look at the UIImage documentation and figure out how to turn a path into a UIImage instance
 
That does not answer the question. How is muscleNames setup. Where do you assign a value to it and populate the array?

If it is a dictionary loaded from a plist what makes you think you can do what you are trying to do? The value assiged to self.imageview.image must be a UIImage. You are not assigning a UIImage. Look at the UIImage documentation and figure out how to turn a path into a UIImage instance

In my first post I listed how I populate the array. I have a constant file that denotes each item as a constant ie:

#define NAME_KEY @"name"
#define DESCRIPTION_KEY @"description"
#define IMAGE_KEY @"image"

I'll take a look at Apple's documentation, it just seemed like something simple.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.