一切工作正常,除了在一個令人不安的延遲後,單元格中的圖像顯示出來。在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