6

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
5
  • your code looks strange... if you would do the setup completely with interfacebuilder and inspector you would not have the ÌBOutlet UIImageView *Heart1`at this point you have.
    – thorb65
    Commented Dec 20, 2013 at 20:14
  • I didn't do all the code in storyboard. I was half doing a tutorial and having doing my own stuff.
    – tomanc
    Commented Dec 20, 2013 at 20:25
  • to understand the basics its better to follow one tutorial ;-) displaying an image inside a view controller is really trivial with storyboard.
    – thorb65
    Commented Dec 20, 2013 at 20:26
  • why is that? All the tutorials I have watched place image views in the view controller
    – tomanc
    Commented Dec 20, 2013 at 20:29
  • Did you solve your problem? Please mark the correct answer to mark this post as answered.
    – Alex Cio
    Commented Jan 31, 2015 at 16:50

7 Answers 7

9

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"

2
  • Thank you so much. Target selection is a tricky one which always traps me :-) Commented Jul 28, 2016 at 12:06
  • 1
    Wow, wasted a day on this. Cheers.
    – David P
    Commented Oct 10, 2017 at 5:52
1

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.

2
  • It's unchecked however now when I run simulator is crashes and I get SIGABRT error. Also, I edited my post to say that ANYTHING I change in storyboard does not change in simulator. Last night my app was working fine and today any changes I make in storyboard do not show up changed at all in simulator.
    – tomanc
    Commented Dec 20, 2013 at 20:59
  • @DuncanC Hi, Duncan. This is not related to your answer here but I just so happened to see your past post from iOS Dev SDK site, in which you mentioned having done some custom UIViewController transitions. I was wondering, since it has been a while, would you mind sharing it as Gist, as I would love to explore more on this? Thanks in advance and Happy Holidays.
    – Unheilig
    Commented Dec 22, 2013 at 18:39
0

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.

3
  • The image has the proper image name and shows the images in the storyboard. I imported the images to supporting files for my project. I added a background to them and ran the simulator and nothing showed. Where is the .xib file and what am I looking for?
    – tomanc
    Commented Dec 20, 2013 at 20:08
  • Oh sorry, I meant storyboard file. K, so we've narrowed down the problem has to do with them not being put on the visible portion of the screen. Since you are not using autolayout, ensure the auto-resizing masks are set correctly. They can be found by tapping the ruler icon (beside the property icon) for each imageview Commented Dec 20, 2013 at 20:12
  • it seems that all auto sizing is off. Also the images are 20x20 so they are small if that helps. Okay so, 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.
    – tomanc
    Commented Dec 20, 2013 at 20:15
0

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

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

0

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

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.