[英]Image shows in the iPad simulator but not the device
我有一个小png,我正在添加到一个视图,我很确定我以前工作但突然停止在iPad上工作,同时继续在iPad模拟器上正常工作。
这是我用来将图像添加到视图的代码...
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];
这发生在UIGestureRecognizerStateBegan事件中。 以下代码删除touchesEnded事件中的图像,即使您看不到它也没有任何错误。
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];
}
}
我不认为这是我在代码中更改的任何内容,因为它在模拟器中工作。 不确定下一步该问题的位置。 我重置了模拟器,看看它是否会在重置后中断。 我也清理了这个项目。
谢谢。
约翰
在此行之后放置一个断点UIImageView *bottomResizer = [[UIImageView alloc]...
然后在控制台上“po [bottomResizer image]”
如果它为零则则资源未正确复制到捆绑包中,或者您可能具有设备无法加载的损坏图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.