一切工作正常,除了在一个令人不安的延迟后,单元格中的图像显示出来。在tableView完成加载后大约0.3秒。我认为很短的时间内显示一个空白图像是非常丑陋的...在UITableVIew加载之前从解析中检索图像?
如何才能让tableView在刚刚加载parse的图像后显示(为什么不从缓存中首先?)。或者我可以让启动屏幕保持更长时间..? TableView是应用程序中的初始视图。
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;
}
感谢提前:)
也许这是真的,但有可能使单元格从缓存中显示图像的第0,3秒?或者至少创建一个像其他应用程序的加载屏幕? – Tibbe 2014-10-28 14:20:26
是的,它肯定是可能的。你会想知道更多关于UIActivityIndicatorView及其用法。 – 2014-10-28 14:21:56
好吧,但更快地设置缓存是不可能的吧?显示启动屏幕直到对象完成加载为止呢? – Tibbe 2014-10-28 14:24:28