2012-10-10 47 views
1

我遇到問題,需要幫助。 我有一張桌子,在單元格上有水平滾動圖像。圖像從互聯網下載。 當我下載第6張圖片時,我的應用程序崩潰。 對於異步上傳我用https://github.com/rs/SDWebImage下載第6張圖片後應用程序崩潰

-(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

難道是你的意思是下載而不是上傳?你告訴「我的應用程序崩潰」。什麼樣的崩潰?從控制檯發佈例外文本。你是否啓用殭屍進行調試? – nullp01nter

+1

抱歉,我的意思是下載圖像。我收到消息收到內存警告。 NSZombieEnabled = YES,但我不能跟蹤錯誤 –

+0

MB我應該使用[經理版]? –

回答

0

既然你得到一個內存警告,我想您的圖片太大,無法在內存中。圖像最多使用內存的width*height*4(取決於顏色深度)。計算每張圖片的內存需求,看看是否有問題。