我有一个小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]”
如果它为零则则资源未正确复制到捆绑包中,或者您可能具有设备无法加载的损坏图像.