iOS应用程序意外关闭
我的iOS应用程序有问题,无法解决。它不断退出,有时当其他应用程序打开时(甚至后台应用程序),整个iPhone都会重新启动 使用xCode提供的分析工具查看时,似乎“ImageIO_JPEG_数据”使用了所有可用的ram 我将附加来自探查器的图像。如果你还需要什么,请告诉我 编辑:找到了!这就是导致它的代码iOS应用程序意外关闭,ios,iphone,out-of-memory,Ios,Iphone,Out Of Memory,我的iOS应用程序有问题,无法解决。它不断退出,有时当其他应用程序打开时(甚至后台应用程序),整个iPhone都会重新启动 使用xCode提供的分析工具查看时,似乎“ImageIO_JPEG_数据”使用了所有可用的ram 我将附加来自探查器的图像。如果你还需要什么,请告诉我 编辑:找到了!这就是导致它的代码 -(void)downloadFromURL:(NSString *)url withPlaceholder:(UIImage *)placehold { if (placeho
-(void)downloadFromURL:(NSString *)url withPlaceholder:(UIImage *)placehold
{
if (placehold) {
[self setImage:placehold];
}
if (url) {
if ([url rangeOfString:@"/Library/"].location != NSNotFound) {
NSData *imageData=[NSData dataWithContentsOfFile:url];
UIImage* image = [[UIImage alloc] initWithData:imageData];
if (image) {
[self setImage:image];
[self setNeedsLayout];
}
return;
}
NSString *strImgName = [[[[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] componentsSeparatedByString:@"/"] lastObject] retain];
AppDelegate *app=[[UIApplication sharedApplication]delegate];
[app applicationCacheDirectoryString];
// NSString *imagePath = [NSString stringWithFormat:@"%@%@",[[AppDelegate sharedObject]applicationCacheDirectoryString],strImgName];
NSString *imagePath = [NSString stringWithFormat:@"%@%@",[app applicationCacheDirectoryString],strImgName];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *aURL=[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
if ([fileManager fileExistsAtPath:imagePath]==NO)
{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(queue, ^(void) {
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:aURL]];
[imageData writeToFile:imagePath atomically:YES];
UIImage* image = [[UIImage alloc] initWithData:imageData];
if (image) {
dispatch_async(dispatch_get_main_queue(), ^{
[self setImage:image];
[self setNeedsLayout];
});
}
});
}
else{
NSData *imageData=[NSData dataWithContentsOfFile:imagePath];
UIImage* image = [[UIImage alloc] initWithData:imageData];
if (image) {
[self setImage:image];
[self setNeedsLayout];
}
}
}
}
显然,这不是我的代码中的错误造成的,不知何故,我使用的sqlite数据库损坏了,删除应用程序并重新安装它似乎已经修复了它。代码、断点、您尝试过的东西,任何有助于诊断问题的东西都会有所帮助。问题中最重要的部分缺失了。这个应用程序实际上在做什么?显示代码,提供详细信息。发布代码将是一个问题,因为我们谈论的是一个非常大的应用程序,没有人会读到:P我可以编写appDelegate,因为它似乎在启动后立即阻塞。好的,只需粘贴导致手机崩溃的部分。不管怎样,200MB的图像?这太疯狂了…这就是问题所在。。。我没有使用任何200 MB的图像。。。