简体   繁体   中英

Image shows in the iPad simulator but not the device

I have a small png that I am adding to a view which I am pretty sure I had working previously but suddenly stopped working on the iPad itself while continuing to work fine on the iPad simulator.

Here is the code I am using to add the image to the view...

  UIImageView *bottomResizer = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"resizeLine.png"]];
  bottomResizer.center = CGPointMake(bottomResizer.center.x, bottomResizer.center.y+self.frame.size.height-12);
  bottomResizer.tag = 301;
  [self addSubview:bottomResizer]; 
  [bottomResizer release]; 

This occurs in a UIGestureRecognizerStateBegan event. The following code in removes the image in a touchesEnded event without any errors even though you cannot see it.

 NSArray *subViews = [self subviews];
 int count = [subViews count];
 for (int i =count-1; i>=0; i--) {
     if([[subViews objectAtIndex:i] tag] == 301) {
         [[subViews objectAtIndex:i] removeFromSuperview];

     }
 }

I don't think it is anything I changed in my code since it works in the simulator. Not sure where to look next for the problem. I have reset the simulator to see if it would break after a reset. I have also cleaned the project.

Thanks.

John

Put a breakpoint AFTER this line UIImageView *bottomResizer = [[UIImageView alloc]...

Then on the console "po [bottomResizer image]"

If it is nil then either the resource is not getting copied correctly into the bundle OR you could have a corrupt image that the device cannot load.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM