1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

problem displaying image from convenience method

Discussion in 'iPhone/iPad Programming' started by schenker, Jul 21, 2011.

  1. macrumors newbie

    #1
    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.

    Code:
    #import "Transition.h"
    
    
    @implementation Transition
    
    
    
    -(void)showSomething
    {
        
        UIImageView *tempoView=[[UIImageView alloc]initWithFrame:CGRectMake(40, 40, 50, 50)];
        tempoView.image=[UIImage imageNamed:@"unlocked4.png"];
        [self.view addSubview:tempoView];
        [tempoView release]; 
    
    }
    
    
    @end
    
    
    Do you have any idea why the image isnt showing up? Thanks.
     
  2. macrumors member

    #2
    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. macrumors newbie

    #3
    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. macrumors newbie

    #4
    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