0

在我的 ios 应用程序中,我使用大量图像(大约一千张)来显示有关产品的信息。然后我在运行时遇到这样的错误;

ImageIO:CGImageRead_mapData 'open' failed error = 24(打开的文件太多)

如何关闭打开的文件?我正在使用 NSFileManager。

谢谢您的回答。

更新:

我的viewdidload中的一些代码,

while(sqlite3_step(compiledStatement) == SQLITE_ROW)  {
                    NSString *imageName= [NSString stringWithUTF8String:(char*)sqlite3_column_text(compiledStatement, 2)];
                    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
                    NSString *documentsPath = [paths objectAtIndex:0]; //Get the docs directory
                    NSString *filePath = [documentsPath stringByAppendingPathComponent:imageName];

                    NSData *pngData = [NSData dataWithContentsOfFile:filePath];
                    if (pngData == nil) {
                        image2 = [UIImage imageNamed:@"resimYok.jpeg"];//horoda
                    }else{
                        image2 = [UIImage imageWithData:pngData];
                    }
                    image2=[image2 imageByScalingAndCroppingForSize:CGSizeMake(175, 210)];

                    UIButton * urunDetayButton = [UIButton buttonWithType:UIButtonTypeCustom];
                    [urunDetayButton setFrame:CGRectMake(column*197+38 , row*350+58, 159, 170)];
                    [urunDetayButton setImage:image2 forState:UIControlStateNormal];
                    [urunDetayButton addTarget:self
                                        action:@selector(buttonClicked:)
                              forControlEvents:UIControlEventTouchUpInside];
                    urunDetayButton.tag = UrunId;
                    [scrollView addSubview:urunDetayButton];

                    UIImageView *background = [[UIImageView alloc]initWithFrame:CGRectMake(column*197+30, row*350, 175, 280)];
                    UIImage *blackBackGround = [UIImage imageNamed:@"BackImage.png"];
                    [background setImage:blackBackGround];                                            
                    [scrollView addSubview:background];
                    [background release];
                    [blackBackGround release];

                    UIImage *sepeteEkleButtonImage = [UIImage imageNamed:@"sepeteEkleButtonImage.png"];
                    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
                    [button setFrame:CGRectMake(column*197+38 , row*350+8, 159, 45)];
                    [button setImage:sepeteEkleButtonImage forState:UIControlStateNormal];
                    [button addTarget:self
                               action:@selector(addToChart:)
                     forControlEvents:UIControlEventTouchUpInside];
                    button.tag = UrunId;

                    [sepeteEkleButtonImage release];
                }

在这个循环中,我创建了数千个按钮。但我看不到一些按钮和一些 imageview 的图像。例如,“背景”和“按钮”图像视图和按钮。有两个截图,那是必须和必须。

这个一定是我想要的 这是当前状态

4

1 回答 1

0

使用下一个语法创建图像可能会更好:

[UIImage imageWithContentsOfFile:filePath];
于 2013-04-29T13:31:18.493 回答