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

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.

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?

Hi-Res #2x image not being picked up for tab bar item

I have a TabBarController that sets the image for the tab like so, in the -init method:
self.tabBarItem.image = [UIImage imageNamed:#"tabImage.png"];
I have a tabImage#2x.png file in the resource. In the iPhone 4 simulator or the phone, the hi-res image isn't being picked up - the low res version is simply being scaled up.
Any ideas why this might be?
EDIT: Some more info:
If I try and explicitly use tabImage#2x.png (or just tabImage#2x) then the tab image I see is extremely large and blown up beyond the bounds of the tab, as if it's being scaled from 60px to 120px. So it looks like whatever name is supply is being treated as a scale=1.0 image.
Note that the simulator is not case-sensitive, but the device is. Make sure case matches EXACTLY. If you've changed the case of the filename at some point, you'll need to clean and rebuild. Sometimes, for the simulator, I've had to actually blow away the folder in Library/Application Support/iPhone Simulator/4.3/Applications/ to get the rebuild to pick up the renamed image.
Always use
[UIImage imageNamed:#"foo.png"]
This will work on 3.x and 4.x devices, and on the 4.x Simulator. Devices with Retina Displays (and the 4.x simulator) will magically pick up the #2x versions of your images; iOS has been modified to be smart about this function and #2x.png files.
Make sure you have both the #2x.png and the normal.png added to the project file, and do a full clean & build. As others have mentioned, verify the size of the images, too; apparently if they're not exactly 2x the dimensions it won't work (I haven't verified this myself).
If you leave the .png off, it will only work on iOS 4.0. So if you're building a 4.0+ only app, you can ask for:
[UIImage imageNamed:#"foo"]
If you have only one hi-res image and want to use it on both Retina and non-Retina devices, then you'll have to change view.contentMode to scale to fit.
I had the same problem. It turned out that my png was not square. Solution: make it square and it will work.
Are you sure the file has been added to the XCode project and is visible in the project explorer?
I had this problem as well.
Make 2 images:
30x30 pixels
60x60 pixels
Suffix the 60x60pixel image with #2x. For example, tabBarImage#2x.png. Then, in your storyboard or code, you can specify the regular one, tabBarImage.png, and iOS will choose the #2x version at its discretion.
You can leave the .png off now. I believe it will still work, but you may try that.
I just went through a few hours of redoing art in The Gimp and trying to get it recognized and loaded by my app on an iPhone 4.
I ran into the problem described with certain images with a #2x extension not being recognized and loaded.
I was not able to discern any pattern. My images are all loaded using [UIImage imageNamed:#"<name>.png"] into a singleton. I inspected the image scale settings post-startup and some were 1.0 (the old art) and some were 2.0 (the new art).
The only way I was able to resolve this problem was to delete and re-add the high resolution images that were not being recognized.
Two silly mistakes (both of which I've made before) that can cause this problem:
Accidentally naming the small
versions #2x instead of the large
ones
Having the large versions be
slightly missized (by one pixel)
you need 2 versions of your images and both ned to be at the same location in the project folder and added to the project
image.png 60x60
image#2.png 120x120
then simply use [UIImage imageNamed:#"image.png"]
did it this way with selfmade buttons and it worked for me (iOS 4.1)
Another thing to look out for is having two images with the same name.
I had the same issue. The #2x image had the wrong build target checked (ServiceTests instead of MyProject).
I had exactly the same problem.
Make two images: im1.png and im1#2x.png
Call imageNamed: with the first one.
Note, imageNamed: doesn't initialize UIImage, hence use it as transient [[UIImageView new] initWithImage:[UIImage imageNamed: #"im1.png"]] or initialize UIImage yourself.

iphone .png image not showing up in device

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.

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.

How to display background image or foreground image of an iphone app

This might come across as a very silly question. I am trying to place an image behind my first "Hello World" app on iphone, since this morning. I tried doing so using Interface Builder using UIImageView object from library and also tried doing so programmatically.
Googling hasn't be much of an help either. Can any one please demonstrate a simple app that shows how to display an image in an iphone app, in background and/or in foreground?
The step you're missing is likely adding the image to the project.
Drag an image from the finder to the Resources section of the project outline. Xcode infers the action from the file type, and images will be copied to the Resources folder. You can check it out in the Targets section of the project outline, if you disclose your Hello World target you'll see the different build phases, including a "Copy bundle resources" build phase.
Anyway once the image is added to your project, the UIImageView inspector image name will autocomplete your image name, and all should work. No code needed.
You could try to add a UIImageView, in IB, to your view and arrange it to the background (behind all labels, etc)
edit: I just realized, you already tried it in IB. I was ignorant, I'm sorry.
The thing is, I do this same trick myself, and it works. If you add a UIImageView to your view in IB, what happens? Does it stick to the foreground? If so, you can re-arrange the position of the object by using the 'Layout' menu.
edit2: I just searched the iphone reference library, and the "Hello World" example also shows how it is done. (http://developer.apple.com/iphone/prerelease/library/samplecode/HelloWorld/index.html)