除了单元格中的图像在令人不安的延迟后出现外,一切正常。 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/