iphone .png image not showing up in device - iphone

ok, i set some .png files image as uimage in my table cell. they show up nicely when i run them using iphone simulator. when i run them in my device, they up not show up. what seems to be the problem?
i only "error" i got is unable to debug when i install my app to my device, which shouldn't be a problem as i never set for debug.
does anyone knows why?
thks in advance!
code:
- (void)setIcon:(UIImage *)newIcon
{
[super setIcon:newIcon];
iconView.image = newIcon;
}
where iconview.image is from nib. newIcon is loaded in from plist, 1.png etc.

Is the uppercase/lowercase letter usage of your file names exactly consistent between the source code or plist strings and the actual file names in your app's bundle? Case awareness is a difference between the Mac OS and iOS file systems.

Related

Images disappear after app released to appstore

There is something very weird in my app after it has been released to the appstore.
Some of the UIImages i used are just missing and seen black from some reasons.
I have checked many times before in device and simulator and it appeared just fine.
Some notes:
I did drag the files and check COPY - the images are in the library for sure
Images DO appears in Copy Bundle Resources under Build Phases
I used these 2 lines in order to get the image:
[UIImage imageNamed:#"email_icon.png"] and [UIImage
imageNamed:#"facebook_icon"]
And i have just noticed that the extensions of the images are PNG not png - maybe is that the reason?
Appreciate your assistance!
Can you replicate this issue on your device? If not I'd recommend deleting the current version from your device and redeploying. You may have cached images on your device which are not allowing you from seeing the issue.
Secondly, yes, filenames on the device are case sensitive. Also make sure that you are properly naming the files and it is not simply a spelling mistake or change from an image name.
Per your line of code you are missing the file extension on the second image
[UIImage imageNamed:#"email_icon.png"] and [UIImage imageNamed:#"facebook_icon"] <-- what type of file is facebook_icon?

Why does png format get changed when on iPhone or iPad Device

Interesting one this. I did do a bit Googling on the it but here we go. I have this png file. What I want to do is have it on my iPhone and send it to a server application on Windows. I use something like this:
NSString *filePath = [[NSBundle mainBundle] pathForResource:IconFile ofType:#"png"];
NSData *icon = [[NSData alloc ] initWithContentsOfFile:filePath];
NSLog(#"File path is %#",filePath);
NSLog(#" Bytes to send in Icon File %d",icon.length);
Now this works just fine when I am on the iPhone simulator. When I go to the device though the png format grows in size. For example I had one that was 2514 bytes and went up to 2652 bytes. When I transmit this file - its not able to be read by the Windows app.
So I assume that when a png file gets copied over in the resource bundle - it must get optimised or something. I can get round it by changing the extension to say .txt - then the file doesnt change.
Does anyone know why that is ? And can you prevent it being changed as I'd rather keep the correct extension. I have seen that png formats need to be converted when you get them from the iPhone but I dont know why this would happen when you upload one and it doesn't work in the simulator mode. Happens with both iPhone and iPad at iOS 5.
The modifying of the png images can be prevented in the build settings - under Packaging there is an option to compress PNG files:
Setting this to NO should solve your problem.
What happens is documented within this document: Viewing iPhone-Optimized PNGs
In short, Apple is using their patched version of pngcrush (note, this one differs from the one available through sourceforge).Their optimizing includes premultiplying the alpha values to speed up the loading process.
You may, as described by the linked document, revert this optimizing if needed (e.g. when reversing existing apps).
The easiest way to prevent this optimizing is to change/remove the file-extension when adding those images to your project.
PNG's are converted to a format "optimized for iPhone". Now this is just what I've read and I'm unsure what the optimization is and if it's actually an optimization, but that's what Apple has chosen to do. Maybe the iPhone GPU is quicker in loading their own format because of hardware support.
In any case, this happens to all PNG images when you deploy a project, and there is no way to prevent it that I know.
If your app downloads a PNG from a remote server this optimization will not occur and you can freely work with the file.
Yes, Apple optimizes all PNGs for display on the iPhone. For example, if you go to iOS .app in the Finder and view its "contents", you will see that all PNGs do not display correctly on Mac OS X.
The solution is to import your file as a "file" rather than an "image". One easy way to do this is to remove the extension then drag it into your project. Another way is to select the image in Xcode and change the File Type under the Identity and Type section in the assistant editor.

cell.imageView is working on Simulator but not on Device

Table view cell imageView is working on the simulator but not on the device..
Some things I have checked.
I have not changed anything in the code.
Image is added to the project and in same folder.
I have one more cell image which is working fine.
Thank you in advance.
Iphone device is case sensitive ... and simulator is not..
Make sure you check the case of the name used in your +[UIImage imageNamed:] calls. These are case-sensitive on the device, but not always on the sim. That's the most common cause of missing images. If that isn't the source, put a breakpoint where you're assigning the image, and check all teh variables.

iphone - not loading ~ipad image

I have 3 images on the same place on my app's bundle: "image~iphone.png", "image#2x~iphone.png" and "image~ipad.png".
when I do
UIImage *imageU = [UIImage imageNamed:[[NSBundle mainBundle] pathForResource:#"image"
ofType:#"png"]];
BOth, the iPhone and iPhone 4 hires versions load fine, but not the ipad image. When I run on iPad, I get nil on imageU.
Yes, the image is there, the name is correct (iphone~ipad.png).
Why is that? any clues?
thanks.
I discovered that the solution for that is: do not use any extension on the iPad images. This tilde trick is not working for iPad. One more buggy stuff that makes us waste time.
Possible daft attempt, but is the ipad image copied into the correct target when you add it as a resource? By that, I mean - of you right click the image and get info, does it have the iPad ticked as it's target?
I ran into the same problem with launch images. Despite what the docs say, naming a file with a ~ipad suffix doesn't do anything. You need to set the UILaunchImageFile~ipad key and use a separate name for your launch images on iPad, e.g., DefaultiPad.png and DefaultiPad-Landscape.png, then make sure to just set UILaunchImageFile~ipad to DefaultiPad (no .png suffix) and it will pick up the variants correctly.
image "image~ipad.png" will show HD quality on iPad because in ios 5.1 "~ipad.png" is used to show HD quality image of resolution 2048*2048.Test this naming conservation on iPad,it will work.

It's working only on simulator, but isn't working on Device

I'm working on sample project for learning core animation. I have problem with my device, I wrote simple project and it's conatins just one viewcontroller and this viewcontroller's view contains just two layer, each layer have .png image backgrounds (actually 700 x 700 px) and these images contains semi transparent content.
You can download example project from here
This project working perfectly on simulator but isn't working on Iphone. I have't seen any error or some thing like that. I have seen empty sreen on device.
Could someone give me suggestions about that please ?
Thank you
Your image file name is "Clouds1.png " but you load it:
[[UIImage imageNamed:#"clouds2.png"] CGImage];
Problem is that file system on iPhone is case sensitive and on MacOS is not. So you must be careful with file names.