【问题标题】:tableview not scrolling smoothly iOS xcode表格视图不能顺利滚动iOS xcode
【发布时间】:2016-05-19 10:00:50
【问题描述】:

每次我在表格视图上滚动并出现一个新单元格时,它都会卡住一毫秒,每次出现新单元格时都会发生这种情况,..我尝试了很多选项..

这是我查询阵列的地方

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

        }
    }];
}

这是我在索引路径中的行的单元格

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

}

【问题讨论】:

  • 别管别人,我自己用 SDWebImage 发现的
  • 即使您自己弄清楚了,也将解决方案发布为答案,而不是编辑。
  • 蒂姆威尔金森,好的,我已经改变了它

标签: tableview smooth-scrolling smooth


【解决方案1】:

我找到了使用 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];
                }
            }];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多