下载第6张图片后应用程序崩溃

时间:2012-10-10 06:23:41

标签: iphone objective-c

我有问题,需要帮助。 我有一张桌子,在单元格上我有水平滚动图像。图像从互联网下载。 当我下载第6张图片时,我的应用程序崩溃了。 对于异步上传,我使用https://github.com/rs/SDWebImage

  -(void) fastCreateImage
   {
int tempID = self.currentPageNow;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.2f * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
    if(tempID==self.currentPageNow)
    {
        NSUInteger objIdx = [self.imageViews indexOfObject: [NSNumber numberWithInt:tempID]];
        if(objIdx != NSNotFound) {
            NSLog(@"WAS CACHED!!!!!!");
        }
        else
        {
             UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 193.5f)];

    NSString *urlInString =[NSString stringWithFormat:@"%@/uploads/gallery/hotels/%@",webSite,[self.urlGarbage objectAtIndex:self.currentPageNow]];
            SDWebImageManager *manager = [SDWebImageManager sharedManager];
            [manager downloadWithURL:[NSURL URLWithString:urlInString]
                            delegate:self
                             options:0
                             success:^(UIImage *image, BOOL cached)
             {
                 myImageView.image = image;
                 [[self.views objectAtIndex:tempID] addSubview:myImageView];
                 [self.imageViews addObject:[NSNumber numberWithInt:tempID]];
                 NSLog(@"LOADED IMG");
             }
                             failure:nil];
            [myImageView release];
        }


    }
});
 }

1 个答案:

答案 0 :(得分:0)

由于您收到内存警告,我猜您的图片太大而无法放入内存中。图像使用内存的最大width*height*4(取决于颜色深度)。计算每个图像的内存要求,看看是否存在问题。

相关问题