UIImageView shows in storyboard but doesn't show up in simulator

9.8k Views Asked by At

I added images using uiimageview in storyboard and connected them to iboutlets and they are not showing up in the simulator. I don't think they are off screen since they are very close to other images and I have auto layout off as i saw in other threads that may be a problem. This is some code if it may help. None of the hearts will show up in simulator.

EDIT: I just moved one of the other images to the center of the screen and when I clean/build/run nothing changed in the simulator. So for some reason anything I change in storyboard is not being carried over into simulator. It all worked last night and I'm not sure what could have change to this afternoon.

#import <UIKit/UIKit.h>

float LeftMovement;
float RightMovement;
float UpMovement;
int life = 3;

@interface Game : UIViewController
{
    IBOutlet UIButton *Start;
    IBOutlet UIImageView *Runner;
    IBOutlet UIImageView *Water;
    IBOutlet UIImageView *Heart1;
    IBOutlet UIImageView *Heart2;
    IBOutlet UIImageView *Heart3;
    IBOutlet UILabel *Lives;

    NSTimer *Movement;


}

-(IBAction)StartGame:(id)sender;
-(void)Moving;
-(void)Walk;
@end
7

There are 7 best solutions below

3
On

We'll need to see how things look in your .xib file. Is the "image" property set with the proper image name? Are you sure the heart images are added to the bundle? To see if the issue is in fact with the positioning of the image views, give the imageviews a background color and see if they are visible.

2
On

I bet the use auto layout flag is checked for your storyboard by accident. Open your storyboard file, select the file inspector, and make absolutely sure that the "Use Autolayout" checkbox is NOT checked.

0
On

Not sure if its too late but anyways.. Did you check in your View container within the attributes inspector that Alpha is set to 1? Because, if it's set to 0 it won't display anything within your view.

0
On

I had the same type of problem for me it was a format issue. I exported a .gif which worked fine in the inspector , but for some reason the sim wasn't having it. A simple change to .png did the trick

2
On

i came up late but the right answer is

Right click on the image in Xcode, go to File Inspector, i had to check the checkbox under "Target Membership"

0
On

Newbie answer but what happened to me is that I called loadView() even though I wasn't adding anything programmatically. loadView() overrides the storyboard.

0
On

The issue for me was resolved (especially running in various simulator devices), with the ImageView, selecting in the Attributes Inspector -> View-> Content Mode-> Scale To Fill.

enter image description here