iPhone n00b here, although I do have an app in the store.
I have two simple ViewControllers, taken directly from the Utility Application template in xCode. I have two UIImageViews, one on each ViewController in a storyboard. I have the outlets hooked up correctly (as far as I know) because I can set the image of the first ViewController fine with
[self.imageView setImage:@"test.png"]
When I try to do essentially the same thing in my FlipsideViewController, nothing happens.
- (void)selectImage:(UIImage *)img
{
NSLog(@"%@", img);
self.editImageView.image = img;
NSLog(@"%@", self.editImageView.image);
}
This code, gives the correct result after logging the first NSLog statement, but the second line does not have the desired effect, and the third line yields (null).
EDIT: the coed is updated to reflect the fact that I want to display “img” rather than another image initialized using imageNamed, that was simply a test.
If you’re passing a
UIImageto your method, why are you then setting theimageViewvia theimageNamed:function?If you’re passing the correct
UIImagethen you should just do the following.From what I can see that is all that is needed. If this is wrong, please update your question so I can answer accordingly.
Edited due to comments
So, from the comments I have gathered what the issue is.
You’re saying that in
-(void)viewDidLoadyou can set the image, that is easy, with the[UIImage imageNamed:]method. That’s fine, but you want to do it in a separate method which is causing the issue.What I’d suggest is doing the following, for testing sakes.
Make sure that the method
selectImage:is added to your.hfile so that you don’t get any warnings. I think this is what the answer is, but if this still doesn’t resolve your question please provide more information.