problem displaying image from convenience method

Discussion in 'iOS Programming' started by schenker, Jul 21, 2011.

  1. schenker macrumors newbie

    Jul 14, 2011
    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.
  2. xcodeNewbie macrumors member

    Jul 1, 2011
    Image View

    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.
  3. schenker thread starter macrumors newbie

    Jul 14, 2011
    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.
  4. schenker thread starter macrumors newbie

    Jul 14, 2011
    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.

Share This Page