Ho un UICollectionView che a implementare il lazy loading,UICollectionView visibleCells restituisce 0 prima di scorrere
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
[self loadImagesToVisiableCells];
}
E funziona bene. Tuttavia, il problema è prima di qualsiasi scorrimento, le prime poche celle mostrano le immagini segnaposto. Così provo a chiamare loadImagesToVisiableCells sul mio richiamo di recuperare il file JSON da visualizzare nella UICollectionView seguito,
- (void)handleReceivedData: (NSArray*)results returnArrayOrDic:(NSNumber *)returnArrayOrDic{
NSLog(@"***************************");
NSLog(@"handleReceivedData has been called from PromotionViewController");
NSLog(@"jsonArray Length:%d",[results count]);
NSLog(@"jreturnArrayOrDic:%@",returnArrayOrDic);
if([returnArrayOrDic boolValue] == YES){
for(NSDictionary *dealDic in results) {
NSLog(@"dealDic: %@", dealDic);
//to populate the dealArray
Deal *deal = [[Deal alloc] initWithDict:dealDic];
[dealArray addObject:deal];
}
NSLog(@"%d deals have been populated to dealArray",[dealArray count]);
}else{
NSDictionary *jsonDictionary = (NSDictionary *)results;
for(id key in jsonDictionary) {
id value = [jsonDictionary objectForKey:key];
NSString *keyAsString = (NSString *)key;
NSString *valueAsString = (NSString *)value;
NSLog(@"key: %@", keyAsString);
NSLog(@"value: %@", valueAsString);
}
}
[self.collectionView reloadData];
[self loadImagesToVisiableCells];
}
messaggio di debug mostra prima di ogni rotolo, [[CollectionView visibleCells] count] ritorna 0.
- (void)loadImagesToVisiableCells{
NSLog(@"starting loadImagesToVisiableCells, visibleCells:%d",[[collectionView visibleCells] count]);
....
}
Qualche idea?
saluti Hammer
Grazie! Imposta come risposta per trovare facilmente –
Grazie per aver postato questo! – yash