UIButton background image not showing up when tested on iphone

Discussion in 'iPhone/iPad Programming' started by stoopkitty, Apr 23, 2011.

  1. macrumors member

    Joined:
    Jan 26, 2010
    #1
    so, I made my app and everything, and it has a few UI buttons with background images, which worked fine when it was on the computer and i was testing in iphone sim.
    now, when i test on a real iphone, the buttons just show up as standard UICustomWhiteRect or whatever it is called.
    here is the code i use to make them:
    Code:
    filepath = [[NSBundle mainBundle]
                pathForResource:@"button-half@2x" 
                ofType:@"png"];
    [sendAsOneSMSButton setBackgroundImage:[UIImage imageWithContentsOfFile:filepath] forState:UIControlStateNormal];
    i also have one for when it is pressed, which i set just like that. and just so no one asks me, the images for the buttons are both in my main folder the same folder my .xcodeproj file is in.
    what could i be doing wrong?

    SO:
    they work in iPhone Simulator
    they show up as normal buttons without images on a real iPhone.
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Make sure when you add the images to your project that the "Copy items into destination group's folder (if needed)" option is checked.
     
  3. thread starter macrumors member

    Joined:
    Jan 26, 2010
    #3
    maybe i wasnt clear...all of the images are in the folder that my .xcodeproj is in. is this what you mean?

    thanks! :)
     
  4. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    And they show up as files within the project in Xcode as well?
     

Share This Page