View Full Version : problem displaying image from convenience method

Jul 21, 2011, 11:18 PM
Hi, I created a convenience method in a class by itself to display an image on screen. I tested it with my mainViewController, but for some reason it didnt show the image on screen. I simplified the convenience method, see .m file below.

#import "Transition.h"

@implementation Transition


UIImageView *tempoView=[[UIImageView alloc]initWithFrame:CGRectMake(40, 40, 50, 50)];
tempoView.image=[UIImage imageNamed:@"unlocked4.png"];
[self.view addSubview:tempoView];
[tempoView release];



Do you have any idea why the image isnt showing up? Thanks.

Jul 21, 2011, 11:22 PM
As far as I can tell, you're code for creating the imageView and adding it to your view is fine. Are you sure this method is being called? And is the name of the image you're using spelled correctly? If it isn't the imageView won't show up.

Jul 22, 2011, 12:03 AM
Yes, no problem with the method being called, 'cos i've already tested it with nslog.
File name is correct too, 'cos i actually copied and pasted from another class that uses this image.

My guess is, could it be anything to do with the views?

//this problem has ruined my appetite :(

Thanks for your reply.

Jul 22, 2011, 01:41 AM
YES! Got it done!

The problem is the view. What i did was, got the current view and passed it to my method in transition.m file. That fixed it.