2016-05-19 33 views
0

我每次滾動的實現代碼如下一個新的細胞出現時,它得到的卡住像毫秒,即發生的每出現一個新的小區時,..我試過這麼多的選擇..的tableview不順利滾動的iOS的Xcode

這是我查詢我的數組

- (void) retrieveStrings { 

    PFQuery *retrieveAllPictures = [PFQuery queryWithClassName:@"String_Pictures"]; 
    [retrieveAllPictures includeKey:@"string_owner"]; 
    [retrieveAllPictures whereKey:@"string_boss" equalTo:[PFObject objectWithoutDataWithClassName:@"String" objectId:original_string_objectID]]; 
    retrieveAllPictures.limit = [loadingNumber intValue]; 
    [retrieveAllPictures orderByDescending:@"createdAt"]; 

    [retrieveAllPictures findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { 
     if (!error) { 

       originalString = [[NSArray alloc]initWithArray:objects]; 
       [self.StringTable reloadData]; 

     } 
    }]; 
} 

這是我行單元格AT索引路徑

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"originalStringCell"; 

    OriginalStringTableViewCell *originalCell = [StringTable dequeueReusableCellWithIdentifier:CellIdentifier]; 

    tempObject = [originalString objectAtIndex:indexPath.row]; 
    userObject = [tempObject objectForKey:@"string_owner"]; 
    originalTempString = [tempObject objectForKey:@"string_image"]; 

[originalTempString getDataInBackgroundWithBlock:^(NSData *data, NSError *error) { 
     if (!error) { 

      originalCell.original_string_image.image = [UIImage imageWithData:data]; 

      CGFloat ImageWidth = ceil(originalCell.original_string_image.image.size.width); 
      CGFloat ImageHeight = ceil(originalCell.original_string_image.image.size.height); 
      CGFloat NewWidth = ceil ((ImageWidth/ImageWidth) * StringTable.frame.size.width); 
      CGFloat NewHeightImageRow = ceil ((ImageHeight/ImageWidth) * StringTable.frame.size.width); 

      originalCell.original_string_image.frame = CGRectMake(0, 53, NewWidth, NewHeightImageRow); 
      NSLog(@"%f",NewWidth); 

      [originalCell.stringIndicator stopAnimating]; 
      originalCell.stringIndicator.hidden = YES; 

      [SVProgressHUD dismiss]; 

     } 
    }]; 

    return originalCell; 

} 
+0

沒關係的人,我一直在使用SDWebImage – user3147328

+0

即使你搞清楚自己,發佈解決方案作爲一個答案,而不是編輯發現它自己。 –

+0

蒂姆·威爾金森,確定THX我已經改變了它 – user3147328

回答

0

我已經找到解決方案使用SDWEBIMAGE。

SDWebImageManager *StringPicturemanager = [SDWebImageManager sharedManager]; 
    [StringPicturemanager downloadImageWithURL:[NSURL URLWithString:originalTempString.  
     options:0 
     progress:^(NSInteger receivedSize, NSInteger expectedSize) { 
      // progression tracking code 
     } 
     completed:^(UIImage *SDWStringImage, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 
      if (SDWStringImage) { 
       NSLog(@"JAAAAAA %@", SDWStringImage); 
       originalCell.original_string_image.image = SDWStringImage; 
       CGFloat ImageWidth = ceil(originalCell.original_string_image.image.size.width); 
       CGFloat ImageHeight = ceil(originalCell.original_string_image.image.size.height); 
       CGFloat NewWidth = ceil ((ImageWidth/ImageWidth) * StringTable.frame.size.width); 
       CGFloat NewHeightImageRow = ceil ((ImageHeight/ImageWidth) * StringTable.frame.size.width); 
       originalCell.original_string_image.frame = CGRectMake(0, 53, NewWidth, NewHeightImageRow); 
       NSLog(@"%f",NewWidth); 
       [originalCell.stringIndicator stopAnimating]; 
       originalCell.stringIndicator.hidden = YES; 
       [SVProgressHUD dismiss]; 
       } 
      }];