我的iOS应用程序有问题我无法解决。当其他应用程序打开时(甚至是后台应用程序),它会一直退出,有时整个iPhone会重新启动。
使用xCode提供的分析工具查看时,似乎“ImageIO_JPEG_Data”使用了所有可用的ram。
我附上了探查器中的图像。如果您还有其他需要请告诉我!!
编辑:找到了!这是导致它的代码
-(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];
}
}
}
}
答案 0 :(得分:0)
显然这不是我的代码中的错误导致它,不知何故我使用的sqlite数据库已损坏并删除应用程序并重新安装它似乎已修复它。