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
tomanc
  • 81
  • 1
  • 6
  • 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 Dec 20 '13 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 Dec 20 '13 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 Dec 20 '13 at 20:26
  • why is that? All the tutorials I have watched place image views in the view controller – tomanc Dec 20 '13 at 20:29
  • Did you solve your problem? Please mark the correct answer to mark this post as answered. – Alex Cio Jan 31 '15 at 16:50

7 Answers7

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"

M.Ali El-Sayed
  • 1,608
  • 20
  • 23
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.

Duncan C
  • 128,072
  • 22
  • 173
  • 272
  • 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 Dec 20 '13 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](http://www.iphonedevsdk.com/forum/iphone-sdk-development/97800-ios-5-container-view-controllers-and-custom-transtions.html) 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 Dec 22 '13 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.

Choppin Broccoli
  • 3,048
  • 2
  • 21
  • 28
  • 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 Dec 20 '13 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 – Choppin Broccoli Dec 20 '13 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 Dec 20 '13 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.

valbu17
  • 4,034
  • 3
  • 30
  • 41
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

Zack117
  • 339
  • 3
  • 14
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

Claytog
  • 618
  • 8
  • 8
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.