views:

54

answers:

3

Here I addsubviews (UIImageViews) it all works on the simulator but not on the device (iOS 4.1) wtf!?

- (void)addChips:(int)value {
UIImage *chipImage;
switch (value) {
    case 5:
        chipImage = [UIImage imageNamed:@"5chip"];
        break;
    case 25:
        chipImage = [UIImage imageNamed:@"25chip"];
        break;
    case 100:
        chipImage = [UIImage imageNamed:@"100chip"];
        break;
    case 500:
        chipImage = [UIImage imageNamed:@"500chip"];
        break;
    default:
        break;
}

int chipCount = [chipsOnBet count];
UIImageView *addChip = [[UIImageView alloc] initWithImage:chipImage];
addChip.opaque = YES;
addChip.frame = CGRectMake((kStackOffset * chipCount) + 131, 268, 57, 57);
[self.view addSubview:addChip];
[chipsOnBet addObject:addChip];
[addChip release];

}

+1  A: 

Well I found the answer in the documentation:

Case-sensitivity: iPhone OS uses a case-sensitive file system, unlike the Simulator which uses a case-insensitive file system by default. Make sure the case-sensitivity of resources accessed within code matches the filename case-sensitivity.

For example, if our filename is "YourExampleImage.png":

Good: [UIImage imageNamed:@"YourExampleImage.png"]

Bad: [UIImage imageNamed:@"YourExampleImage.PNG"]

Bad: [UIImage imageNamed:@"yourexampleimage.png"]

so I just have to ensure my image names are the same case as my resources. So in my case I should of put 5Chip instead of 5chip.

Thanks

Daniel Granger
Whether the simulator is case-sensitive should depend on your Mac's FS. You can set up HFS+ to be case sensitive, but by default it's case insensitive but case preserving...
DarkDust
+4  A: 
  1. Make sure you write the correct file names, iOS is case sensitive, simulator is not.
  2. Make sure you have the proper retina files if you test on iPhone4
Alin
+1  A: 

Hello denial, u r going to use your image, names only.Not with image extension.U should use ur full name image as

[UIImage imageNamed:@"a.png"];

make sure ur image name should be same as u stored in resource folder.

singhSan
Since the introduction iOS4 you no longer have to put the file extension if your referring to a resource loaded in your project
Daniel Granger