cell.imageView is working on Simulator but not on Device - iphone

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.

Related

UITextView BackGround image iphone

I m working on note app. In which i m creating view like iPhone notes.
First i took a scroll view and then one image view. After that I m creating a UITextView dynamically... I set the background image of UITextView..
using this code
textView = [[UITextView alloc]initWithFrame:CGRectMake(0,30,320,400)];
textView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed: #"lines.png"]];
Its working perfect in simulator. but when i run my app on device then UITextView's background doesn't display... means it doesn't display lines...
My image size is 365x45...
Can anybody help me why this happen???? Where is the problem???
thanks!!
I had a similar problem once and got grey hair over it. :)
Double check whether your background image file (the .png or whatever) is still boundled with your app. Check this with the project or tartet settings when you have multiple targets.
In my case the file was included in the project but not in the boundle. For reasons that I never understood it was part of the bounle installed on the simulator. It was even there when I deleted the app manually from the simulator's file system. Re-launched the app in the simulator and it was there again.
But when I checked the content of the boundles that where sent to debug devices or the store, the image file was missing.
The same problem may occour to you.
I never used that method. What I do is I put an invisible UITextView over the UIImageView

UIImageViews don't load in UIScrollView using imageNamed method

Can someone tell me the difference between these two means of loading an UIImageView?
iconView.image = [UIImage imageNamed:anIconFileName];
and
iconView.image = [UIImage imageWithContentsOfFile:anIconFileName];
I ran into a situation where when using the imageNamed method I had non-deterministic behavior loading the UIImageViews as subviews on a UIScrollView. The UIImages would load in the simulator, but not on a device using may iMac. But when I moved to my Mac Air everything worked as expected in both the simulator and the device? With further investigation, I found that it was nondeterministic when it worked. I was trying to load 5 UIImageViews and sometimes I would get 1 or maybe two. Getting any to load at all seemed to depend on the size of the *.png files I was trying to load.
When I changed with the imageWithContentsOfFile method everything worked as expected... reliably.
The UIImages didn't seem to be to large - about 100K each. Any thoughts would be helpful.
First thing - have you checked the name of image, because simulator load case insensitive image as well, while device will not load that.
imageNamed - this method takes file name.
imageWithContentsOfFile - this method take complete file path of that file name.
So above code which you have mentioned is dummy code or actual code, and if that is actual code then you need to be sure that with imageNamed you have to pass file name and with imageWithContentsOfFile you have to pass file path.
Check out this article for difference between these two method -
http://www.jorambarrez.be/blog/2012/04/19/ios-imagenamed-vs-imagewithcontentsoffile/
It's nothing to do with the UIScrollView just check the way you imported the images to Xcode. You should add files selecting the option:
Create groups for any added folders.
That way the folder will show in yellow (instead of blue) and imageNamed will work fine.

UITableView refuses to populate on my Device

I am using a Data.plist file to populate my UITableView/Navigation-based Application with data. it works perfectly on the simulator, and it shows up all 261 names, with the subtitle. The detail view also works 100%.
But, no matter what I do, reboot, clean, comment out, it refuses to show up on my Device. (iPhone 3G, unfortunately. Soon to be iPhone 4).
I have a Footer on my Table View that calculates the amount of Cells and totals them up for me. "Movies: 261" is what it shows. Yes, my app is an in-house only app that is my DVD Index.
But, on the Device, it shows "Movies: 0" even though the Data.plist is there, and everything should be working.
Is there anything I'm doing wrong? Can anyone help me?
Thank-you.
Sorry, problem fixed. Turns out the iPhone itself is CaSe SeNsItIvE where as the Simulator is not. So, if the PLIST file you're using is called "Data.plist" and it's referenced as "data.plist" in your code, it will NOT populate on the Device.
I hope this helps everyone who had the same problem as I did. :)
Thanks,
BenBen

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.