Works on iPhone Simulator but not on device

Here I addubviews (UIImageViews) everything 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]; } 
+6
iphone uiview uiimageview
source share
3 answers
  • Make sure you write the correct file names, iOS is case sensitive, and the simulator is not.
  • Make sure you have the appropriate retina files if you are testing on iPhone4
+19
source share

I found the answer in the documentation:

Case Sensitivity: iPhone OS uses a case-sensitive file system, unlike Simulator, which uses a case-sensitive file system by default. Make sure that resource sensitivity case sensitivity within the code matches the file name case sensitivity.

For example, if our file name is "YourExampleImage.png":

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

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

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

So I just have to make sure that the names of my images are the same case as my resources. Therefore, in my case, I have to put 5Chip instead of 5chip.

+3
source share

You are going to use your image, only names. Not with image extension. You must use the full name of the image as

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

Make sure that the image name matches the one you saved in the resource folder.

0
source share

All Articles