gpt4 book ai didi

iphone - 图片IO : CGImageRead_mapData 'open' failed error = 24 (Too many open files)

转载 作者:行者123 更新时间:2023-11-28 18:02:21 25 4
gpt4 key购买 nike

我正在使用 Uikit + Uiimages 开发一个小游戏应用。在正常情况下,我的应用程序运行没有任何问题。但是当我贸然使用时它会崩溃并报错

<Notice>: ImageIO: CGImageRead_mapData 'open' failed '/var/mobile/Applications/01E69C96-CF79-466F-93AB-3A6752AF1295/PictureBook.app/NextPage.png'

<Notice>: error = 24 (Too many open files).

我将在使用完成后发布所有图片浏览量和视频。我用泄漏工具测试了我的应用程序。也没有泄漏。没有警告,没有潜在的泄漏等......

我搜索了一个好的答案,但我还没有得到合适的答案。谁知道答案,请回复。我在下面发布了一些代码。

- (NSMutableArray *)flowerArray {

if (!_flowerArray) {

_flowerArray = [[NSMutableArray alloc]init];

for (int i = 1; i <= 5; i++) {

UIImage *flowerIm = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"01_Flower_0%d.png",i] ofType:nil]];

[_flowerArray addObject:flowerIm];

[flowerIm release];

}

}

return _flowerArray;
}


-(void)flowerImagesAnimate {

self.flowerImage.animationImages = self.flowerArray;

self.flowerArray = nil;

self.flowerImage.animationDuration = 1.0;

self.flowerImage.animationRepeatCount = 3;

[self.flowerImage startAnimating];

}



-(void)playerPrepare
{

[self.view addSubview:[self.presentView playerPrepare]];

}
-(void)wakeUPPanjo
{
NSString *url = [[NSBundle mainBundle] pathForResource:@"01_Anim"
ofType:@"mp4"];

NSURL *movieURL = [NSURL fileURLWithPath:url];



self.presentView.player = [[MPMoviePlayerController alloc]
initWithContentURL:movieURL];




[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.presentView.player];

[self.presentView.player prepareToPlay];

[self performSelector:@selector(playerPrepare) withObject:nil afterDelay:0.5];

wakeUpTimer = nil;


}


-(void)viewLoad
{

wakeUpTimer = [NSTimer scheduledTimerWithTimeInterval:videoDelay target:self selector:@selector(wakeUPPanjo) userInfo:nil repeats:NO];

[self performSelector:@selector(flowerImagesAnimate) withObject:nil afterDelay:flowerPopupDelay];
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.

[self performSelectorOnMainThread:@selector(viewLoad)
withObject:nil
waitUntilDone:false];
}

最佳答案

尝试在整个项目中使用 initWithContentsOfFile 来加载图像,而不是 UIImage 的 imageNamedimageNamed 是自动释放的如果你有太多的图像会导致严重的问题,苹果本身建议减少自动释放对象的使用。

iPhone OS Note: Because on iPhone OS an application executes in a more memory-constrained environment, the use of autorelease pools is discouraged in methods or blocks of code (for example, loops) where an application creates many objects. Instead, you should explicitly release objects whenever possible.

关于iphone - 图片IO : CGImageRead_mapData 'open' failed error = 24 (Too many open files),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7711680/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com