Xcode 6: Images Not Showing Up On Device - ios

I am creating UIImageView(s) and adding these views to a UIScrollView. The images show up when I am testing on a simulator, but when I test on an iphone 5s the images don't show up. Below is a list of things I have tried:
Clean Build
Reinstall App
Then I thought maybe it was a problem with retina images so I added retina images (the images are white pngs):
I am using the images as such:
UIButton *doneBttn = [UIButton buttonWithType:UIButtonTypeCustom];
[doneBttn setImage:[UIImage imageNamed:#"addButton.png"] forState:UIControlStateNormal];
[doneBttn setImage:[UIImage imageNamed:#"addButtonSelected.png"] forState:UIControlStateHighlighted];
[doneBttn setFrame:CGRectMake(0, 0, 50 , 30)];
[doneBttn addTarget:self action:#selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
[uiNavView addMenuBarButtonRight:doneBttn];
I know the code above works, because the image is displayed in the simulator.
What do I need to change to get the image to display on my device? Also, I have checked to make sure the files are in the xcode project directory, and not just linked.

I also faced this issue once, the cause of this issue was that I am not taking care of image name by assigning it to UIImageView, make sure that you are assigning UIImageView the exact name of the image as it is in the main bundle.
The simulator can read the image name if there is any case-sensitive issue or some extension issue like i.e. .png , .jpg, but device never reads the image name if there are issues in the naming conventions, device always treat the image name as exact.

Related

Gimp Settings to Create a Tintable Icon in iOS

I have a PNG file that's an arrow that I'd like to use as an icon in an iOS app. I've dropped other PNG files into Xcode and they work fine as tintable UIButton images using this line as an example:
[self.backButton setTintColor:[UIColor redColor]];
With the PNG file I dropped in, the file I'm dropping in is transparent except for the arrow, which is black. The code above does nothing to the image I'm trying to tint.
I've found other posts covering this topic, but rather than type 10-20 lines of code for each icon I've got on a UIButton, I'd rather save it with the correct settings in Gimp and just reference the file in Xcode.
What settings should I pay attention to when saving the file as a PNG in Gimp?
Update
I initially thought adding the tint was causing my app to crash, however a cache clean resolved that issue. Regardless, my UIButton with a PNG background won't change tints. It's always black, though it turns charcoal (darkGray?) colored if the button is disabled.
Update 2
I've tried this without any luck:
self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *backButtonImage = [[UIImage imageNamed:#"back"]imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.backButton setImage:backButtonImage forState:UIControlStateNormal];
self.backButton.tintColor = [UIColor myCustomColor];
I gave up and opted for a UISwipeGestureRecognizer--works out better for the interface, so no compromise. Apparently, you can tint some buttons, but not others.
https://stackoverflow.com/a/11066046/4475605

iOSOpenDev Including Images

I am trying to use iOSOpenDev to build a jailbreak tweak. I am used to doing everything in programmatically and without using interface builder. I want add a background to my UIButton by doing this.
button setBackgroundImage:[UIImage imageNamed:#"arrow.png"]forState: UIControlStateNormal];
When I run the code on my iPhone, the background image is not displayed. I have the image in the same directory as my tweak.xm file. How would I give the UIButton a background of this image? I would easily be able to in a regular application by adding it to the project assets, but there isn't one in the Logos template.
Any help would be appreciated.

Picture doesn't show on iPhone when running app

I have set the backgroundColor to a picture which is located in the project folder. When I run the app in the simulator the pic is shown. But when running on my real iPhone it's just white. What can be causing this? Could it be because I have <0.5gb free on both the computer and iPhone?
I had similar situation.
It seems the simulator - Xcode is cacheing the image somewhere, but at build time is loosing.
Try: uninstall the app from simulator, device.
Clean the project.
Force close XCode, not just the project, close it.
Open, clean project, build
At this step should match the device and simulator behaviour, hopefully it is there the desired image.
Please check spelling of the image name you used. In actual devices it's case sensitive.
That should be plenty of free memory. When adding the file to your project, and make sure you choose the options for the image to be copied into the project and to be part of the target.
EDIT: my above suggestion is only useful if the UIImageView you are trying to load points to a picture, and I guess in this case you are just using a blank UIImageView and setting background color.
Also, you might want to look at the arrangement (ie. send to back, send to front, etc. Try sending to front in case there was something in front of it blocking the view) I think these options are in the menu bar under Design --> Arrangement
Could you post some code?
You'll want to add the image not as a backgroundColor, but as a UIImageView subview.
// load the image
UIImage *image = [UIImage imageNamed:#"image.png"];
// create the image view using the image
UIImageView *imageView = [UIImageView alloc] initWithImage:image];
// add the image view as a subview
[yourview addSubview:imageView];
First try to Uninstall the app Clean the project then Install and then check if not then.
Second there may some issue with picture spelling Case senstive or Not As The iPhone is case sensitive, but the simulator is not because iPhone file system is case sensitive and Mac OS is not
Third
Add a break point where you add UIImage
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 100, 50)];
imgView.image = [UIImage imageNamed:#"a_image.png"];
Then on the console "po [imgView image]"
If it is nil then either the resource is not getting copied correctly into the bundle.

Image invisible in iPad because wrong Xcode folder management

I have small problem. When I launch my app in emulator it works just fine, but when I launch it on my iPad I cant see the images of the buttons. The background is OK. Image 1.jpg is shown, but images in General folder like contour buttons is invisible on iPad. Other images like Glasses.png that in other screen are shown fine also. The image 1.jpg is defined via code:
- (void)viewDidLoad
{
[super viewDidLoad];
[mainImgae setImage:[UIImage imageNamed: #"Iview images/Bike/100/comp/1.jpg"]];
}
And other images for buttons selected via storyboard. I think my folder management is wrong, but i have to manage it in folders, so they will be in folders at my project folder.
[mainImgae setImage:[UIImage imageNamed: #"1.jpg"]];
this is enough for putting image for mainimage.,.

Custom button not appearing on iOS device

So I'm trying to implement a custom button in my iOS app to replace the default rounded rectangle button. Heres a code snippet:
UIImage *normalImage = [[UIImage imageNamed:#"Images/whitebutton.png"] stretchableImageWithLeftCapWidth:12.0 topCapHeight:0.0];
UIImage *pressedImage = [[UIImage imageNamed:#"Images/bluebutton.png"] stretchableImageWithLeftCapWidth:12.0 topCapHeight:0.0];
[self.theButton setBackgroundImage:normalImage forState:UIControlStateNormal];
[self.theButton setBackgroundImage:pressedImage forState:UIControlStateHighlighted];
When I run it in the simulator everything works fine, my custom button shows up. However, when I run it on my actual device the button just appears as the default one with no customisation at all. Anybody got any idea where I'm going wrong?
The iOS file system is case sensitive, unlike the sinulator's. I'd start by checking that "Images" directory.
(Quick test if I'm barking up the wrong tree: does the +imageNamed: call return nil?)
You should add whitebutton.png and bluebutton.png to your project. And call imageNamed:#"filename" not imageNamed:#"file path" . Also , when running on the simulator there is no problem with case sensitivity. On the device , you have to type the correct name of the file because it IS case sensitive.
Hope this helps.
Cheers,
George
Your resources are going to get flattened in your app bundle. Also, the filesystem on iOS is case sensitive while the filesystem on Mac OS X is case preserving, so make sure the actual filenames of your images are case-correct. If they are, just remove the Images/ prefix and it should work:
[UIImage imageNamed:#"bluebutton"];
Also, if the image is a png type, you don't need to specify the file extension with imageNamed:.
Use
[UIImage imageNamed:#"whitebutton.png"]
and
[UIImage imageNamed:#"bluebutton.png"]
Regardless of how you have it visually organized in Xcode, it all gets flattened in the bundle

Resources