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

拜拜、爱过 提交于 2019-12-07 04:45:18

问题


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

回答1:


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:


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.




回答3:


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.




回答4:


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.




回答5:


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




回答6:


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.



来源:https://stackoverflow.com/questions/20711073/uiimageview-shows-in-storyboard-but-doesnt-show-up-in-simulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!