“数据格式化程序暂时不可用…”错误

可能重复:
编程接收信号:“0”。 数据格式化器暂时不可用

我在XiB上面做了200多个OBShapedButton,并在那里设置背景图片。 之后,我将拍摄该特定OBShapedButton的图像,并将该图像着色并将其设置为该OBShapedButton的背景。

-(void)onTick:(NSTimer *)timer { //Database UIImage *setColor=[[UIImage alloc] init]; for (int i=0; i<[dataArray count]; i++) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; currentLevelMaleValue =[[[dataArray objectAtIndex:i] objectForKey:@"CurrentLevelMaleColor"] doubleValue]; printf("Current val is %f",currentLevelMaleValue); for (OBShapedButton *obshapedCountryButtons in scrollBaseView.subviews) { if (obshapedCountryButtons.tag==i+1) { UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapButton:)]; tap.numberOfTouchesRequired=1; tap.numberOfTapsRequired=1; [obshapedCountryButtons addGestureRecognizer:tap]; [obshapedCountryButtons addTarget:self action:@selector(buttonTagTrap:) forControlEvents:UIControlEventTouchDown]; //[obshapedCountryButtons addTarget:self action:@selector(tapButton:) forControlEvents:UIControlStateHighlighted]; setColor=[obshapedCountryButtons imageForState:UIControlStateNormal]; countryCode =[self getCountryColorCurrentLevel:currentLevelMaleValue]; setColor =[setColor imageTintedWithColor:countryCode]; [obshapedCountryButtons setImage:setColor forState:UIControlStateNormal];[pool release]; // [setColor release]; // [obshapedCountryButtons release]; // [tap release]; // } // } } } } 

现在,我得到这个错误[循环执行了大约40次之后] –

编程接收信号:“0”。 数据格式化器暂时不可用,将在“继续”之后重新尝试。 (未知错误加载共享库“/Developer/usr/lib/libXcodeDebuggerSupport.dylib

接收到这个警告 –

收到内存警告

然后,该应用程序正在终止。

注意 :

没有对象分配。

请帮助我一些你的想法。 我该怎么办?

 UIImage *setColor=[[UIImage alloc] init]; 

是一个内存泄漏,因为你不释放它。 实际上,分配是不必要的,因为您正在为其分配一些其他值。 同样, tap也不会像您所评论的代码一样被释放。

这个build议。 尝试把这块代码放在NSAutoreleasePool

编辑:

 -(void)onTick:(NSTimer *)timer { //Database UIImage *setColor;// =[[UIImage alloc] init]; for (int i=0; i<[dataArray count]; i++) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; currentLevelMaleValue =[[[dataArray objectAtIndex:i] objectForKey:@"CurrentLevelMaleColor"] doubleValue]; printf("Current val is %f",currentLevelMaleValue); for (OBShapedButton *obshapedCountryButtons in scrollBaseView.subviews) { NSAutoreleasePool * pool1 = [[NSAutoreleasePool alloc] init]; if (obshapedCountryButtons.tag==i+1) { UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapButton:)]; tap.numberOfTouchesRequired=1; tap.numberOfTapsRequired=1; [obshapedCountryButtons addGestureRecognizer:tap]; [obshapedCountryButtons addTarget:self action:@selector(buttonTagTrap:) forControlEvents:UIControlEventTouchDown]; //[obshapedCountryButtons addTarget:self action:@selector(tapButton:) forControlEvents:UIControlStateHighlighted]; setColor=[obshapedCountryButtons imageForState:UIControlStateNormal]; countryCode =[self getCountryColorCurrentLevel:currentLevelMaleValue]; setColor =[setColor imageTintedWithColor:countryCode]; [obshapedCountryButtons setImage:setColor forState:UIControlStateNormal];[pool release]; // [setColor release]; // [obshapedCountryButtons release]; [tap release]; } [pool1 drain]; } [pool drain]; } } 

用仪器分析您的应用程序来检查内存泄漏。

如果没有泄漏,那么你正试图分配太多的内存,因为200个button可能是很多。 唯一的解决办法就是加载懒惰:在任何时候,只能在内存中看到用户可见的button。

内存警告是苹果在iOS中实现的内存pipe理方法。 如果设备内存不足,则会发出内存警告。 它期望每个正在运行的应用程序通过清除尽可能多的脏内存来响应此警告。 它会做三轮记忆警告。 前两个级别是清除记忆的基本信息。 如果你没有及时响应,或者没有足够清晰的内存,那么你的应用将会被终止,因为它不能很好地与iOS一起玩。

粘贴return;if (obshapedCountryButtons.tag==i+1)块的末尾。 取消注释[setColor release]; [tap release]; [setColor release]; [tap release]; 码。 用当前标签查找对象是个坏主意。 将foreach循环replace为一些查找块。

 index = [scrollBaseView.subviews indexOfObjectPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) { }