Images not all showing up on simulator but shows in storyboard
Asked Answered
B

11

13

I am pretty new to iOS development and I was poking around in storyboard in Xcode 4.5.2. I started a new tab bar project (5 tabs) and then dropped in some images (UIImageViews objects) to them, everything looked good and the build came out fine on the simulator but not all the images are showing up. The same image would be showing on the Firstviewcontroller but it won't show on another viewcontroller. And I can't seem to add new image objects into the firstone (meaning i can place it in the storyboard but new ones won't show up on the simulator), It almost seems to be showing cached screens. For example, I just randomly place images all over a viewcontroller and then shifted them around and ran the simulator again but the positions do not match.

Does anyone have any information or experience with this on Storyboard?

Thanks in advance. Ray

Bindle answered 18/1, 2013 at 15:17 Comment(11)
Which simulator are you using? iPhone 5 or 4?Audet
Just iPhone (non-retina), but I switched it over to the 3.5inch and 4inch retina iPhones and still the same.Bindle
Try to do a clean and build. It is under the product menu. First select clean, then build. Then try running it again. Are you sure the pictures aren't just out of the view with auto layout?Audet
Thanks. Hmm..I did a Product>Build and then got this failure:Bindle
2013-01-19 02:11:04.811 Interface Builder Cocoa Touch Tool[3097:f07] CFPreferences: user home directory at file://localhost/Users/ray/Library/Application%20Support/iPhone%20Simulator/User/ is unavailable. User domains will be volatile.Command /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ibtool failed with exit code 255Bindle
I have never seen that one! Did you try to clean it as well?Audet
Douglas I actually started a brand new project just to try again and same thing happened again. The simulator images do not match those that are on the storyboard. I did Build/Clean many times along the way and there weren't any errors. Still stuck... :(Bindle
I will try looking into this weekend. But I have never seen anything like this. It is very odd, I would say delete your derived data, but you made a totally new project and the same thing happened. It is odd. Get back to you.Audet
Thanks @Douglas, here is a look if you want to see what I am seeing. I just placed two lines on the storyboard on the right, ran the simulator (left), and that's what would happen. I had a bunch of other images as well, just random 50x50 pngs just to try. I laid it all out randomly and soon it would only show some and not others. It almost seems it would only show on the top half of the screen. I'm trying to pin point where things get complicated. i49.photobucket.com/albums/f283/akamaddisk/…Bindle
I also have a customised tab bar, not sure if that has anything to do with it... I have this: UITabBar *tabBar = [UITabBar appearance]; [tabBar setBackgroundImage:[UIImage imageNamed:@"tabbar.png"]];Bindle
Whenever you add images (or any resource) to the project, always pick "Copy" so that they get copied into the project folder and you don't end up with external dependencies.Nashville
L
6

I had a similar issue. But later found out that this was because I had put the images in a real folder in the app directory. So there was my project's folder, which contained another folder named 'Assets' which contained the images. This was solved when I moved my images out of the folder and put them in the project's root folder.

Liberalize answered 2/1, 2014 at 12:22 Comment(1)
Thanks, this saved my sanity! The images would show up in Interface Builder but not when running the app. Thanks!Cyrstalcyrus
C
6

In my case when I have created new project in Xcode 6 I can not show the images in the Simulator and as well as in device. I have imported all the images in the image assets making a folder within that.Now I have imported all the images, all are working fine now. All images are now showing now.

Follow these steps:

STEP 1:

Step 1:

STEP 2:

Step 2

STEP 3:

Step 3

and then Import images which you need. Reference Link: StackOverflow link

Cacomistle answered 25/11, 2014 at 13:26 Comment(0)
L
4

In my case the picture was a JPG and not a PNG. Replacing image in xcasset for the same image converted to PNG was the trick.

Latoya answered 30/12, 2014 at 19:43 Comment(0)
A
2

Restarting simulator fixed my problem. I think it was a cache problem.

NOTE: I'm using iOS 10 with xcode 8

Avionics answered 30/4, 2017 at 6:18 Comment(0)
A
1

I encountered this problem after I refactored storyboard. The possible solution: - Go to Storyboard and select the image you don't see in the simulator. - Go to the Attributes inspector and re-select the image again.

After Storyboard refactor, sometimes Xcode assigns Unknown image to the UIImageView.

Reselecting the image solved the problem.

Amalia answered 6/8, 2019 at 7:58 Comment(0)
H
1

It happens when you change the folder for your storyboard or image. (Possibly copied storyboard from another project).

Find your Image in the Project Navigator, Select it and change it's location to (Relative to Project)

enter image description here

If necessary, you'd need to relink your image.

Hireling answered 24/8, 2019 at 8:22 Comment(0)
A
0

@PressRay, I have been toying around with things and have some suggestions. I have moved this to an answer, because they would have put us in chat if we kept going. But hopefully this will do it. First off, I think you should make your tab bar from interface builder, perhaps you have input some code incorrectly. You can either start one from the first screen of create a new project, or you can drag one in from the library. But it is a Tab Bar controller. Then for each of your five views, you can place a view controller on the screen for it. Then you can drag from your tab bar controller to each of the five new view controllers and select relationship tab bar controller. This will set up each vc for you.

Next I would suggest you turn off auto layout to get a feel for story boards first before you jump into auto layout and constraints. That is why I think your png's are not showing up. The two lines look like they are too close together because of some contraint moving them. To do this select the view controller, make sure it is just the view controller and then in the right hand view, go to the file inspector, it looks like a page icon. Under Interface Builder Document should be a check box for Use Autolayout. Click this so there is no check mark. Now you will be using struts and spring on each vc that you turn this off. So go ahead and turn it off on all of them.

Next you have some png files to put in. Drag your image views to wherever you want them in any of your vc's. Then hook up the png files by selecting the image view and then once again on the right hand view select the attributes inspector and under the drop down menu of Image find the png that you want. Then you can move the image views anywhere in the vc that you want. I think this will solve your problem. Let me know what happens or if you have any questions.

Audet answered 20/1, 2013 at 18:51 Comment(3)
Thanks Douglas for your efforts. It was the auto layout that was placing things all weird. One simple checkbox!Bindle
@PressRay, Glad to help! If you could check the checkmark at the top of the answer, that will accept the answer and it will be considered closed, so others will know. You can also one up by pressing the up arrow. Thanks. Have a great day.Audet
@PressRay, Think you could accept the answer? Thanks. Glad it worked out.Audet
M
0

For xcode beta (swift 4) converted the jpg to a png file, and created a folder called images.xcassets, added the png file to the folder. It worked going to try adding the jpeg to the folder and see if the image shows up. I just tried the jpeg and its not showing up. So my conclusion is to use png files and create a folder to hold the png files. Add the folder right after the Main.storyboard. Hope this helps.

Moramorabito answered 4/9, 2017 at 5:5 Comment(0)
H
0

I just changed the image/file names. Sometimes if there is a continuous pattern xcode gets stumped. So if you have image_1, image_2....change to 3_image. This fixed my problem.

Hooded answered 16/12, 2020 at 1:56 Comment(0)
I
0

Solution that worked for me was to add images.xcassets folder, Build phases of project inside compile bundle resources

Xcode version 14.3 on iOS 16.4 simulator

Innes answered 1/8, 2023 at 15:32 Comment(0)
C
-2

try to check the image properties in your project in case you haven't set them not yet set

to

after set

Coccidioidomycosis answered 14/8, 2019 at 8:2 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.