ios - 在加载 UITableVIew 之前从解析中检索图像?

标签 ios objective-c uitableview uiimageview parse-platform

除了单元格中的图像在令人不安的延迟后出现外,一切正常。 tableView 完成加载后大约 0.3 秒。我认为短时间显示空白图像非常难看...

如何让 tableView 在解析的图像加载后立即显示(为什么不先从缓存中加载?)。或者我可以让启动屏幕保持更长的时间..? TableView 是应用程序中的初始 View 。

queryForTable

- (PFQuery *)queryForTable {
    PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];

    // If no objects are loaded in memory, we look to the cache
    // first to fill the table and then subsequently do a query
    // against the network.
    if ([self.objects count] == 0) {
        query.cachePolicy = kPFCachePolicyCacheThenNetwork;

    }

    [query orderByAscending:@"name"];

    return query;
}

cellForRowAtIndexPath

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)objects
{
    static NSString *simpleTableIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
    }

    //loading icons
    PFFile *thumbnail = [objects objectForKey:self.imageKey];
    PFImageView *thumbnailImageView = (PFImageView*)[cell viewWithTag:100];
    thumbnailImageView.file = thumbnail;
    thumbnailImageView.image = [UIImage imageNamed:@"placeholder.jpg"];


    [thumbnailImageView loadInBackground:^(UIImage *image, NSError *error) {
        if (!error) {

        }
    }];



    //cell
    cell.textLabel.text = [objects objectForKey:self.textKey];

    return cell;
}

提前致谢:)

最佳答案

在短暂的延迟后加载图像没有坏处。这是一个标准程序,许多世界一流的应用程序都遵循这一程序(尝试在 Facebook 或 Twitter 应用程序中滚动)。解决这个问题的工作在逻辑和程序方面会非常困惑。

关于ios - 在加载 UITableVIew 之前从解析中检索图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26610375/

相关文章:

iphone - 奇怪的崩溃报告

ios - -[__NSCFString countByEnumerateWithState :objects:count:]: unrecognized selector sent to instance

ios - 在谷歌地图上绘制虚线圆圈 : iOS

ios - 出现错误 : module "QtPositioning" plugin "declarative_positioning" not found

ios - 抑制 Swift 编译器警告

objective-c - 为什么不停止 iOS 模拟器中的应用程序触发 applicationWillTerminate :?

swift:索引超出范围

ios - 如何使用 UISwipeGestureRecognizer 检测 UITableViewCell 中的滑动事件

iPhone SDK - 突出显示 TableView 中选定的单元格

ios - 区分何时调用 UIApplicationDidBecomeActiveNotification