iphone - Calc UICollectionViewCell height while downloading image from internet -
i want create water fall layout using chtcollectionviewwaterfalllayout. noticed in demo cell height fixed , it's in array. but, right now, got image url , want show on screen, height not knowing. so, heightforitematindexpath datasource not working. how calc height of image url before it's downloaded. or can downloading , displaying image in cellforitematindexpath datasource method while calc height , set cell height in heightforitematindexpath datasource method? how that?
if image downloaded own server, recommend send meta data first showing image dimensions , use calculate height before downloading image.
if image isn't on server, best solution add bool array indicating whether corresponding image downloaded or not, if downloaded, adjust height, if not, use default height.
and add delegate cell calls below method when image loaded:
- (void) imageloadedatindexpath:(nsindexpath)indexpath { [self.tableview beginupdates]; [self.tableview reloadrowsatindexpaths:[nsarray arraywithobjects:indexpath, nil] withrowanimation:uitableviewrowanimationnone]; [self.tableview endupdates]; }
hope helps.
Comments
Post a Comment