i have take images firebase storage. changing images while scroll , down in table view. tried thing s on internet , stack overflow, no luck. below code.
#import "tableviewcontroller.h" #import "customcell.h" #import "detailviewcontroller.h" #import "dataobj.h" #import "mzformsheetpresentationviewcontrollersegue.h" #import "browsetableviewcontroller.h" #import "favouritestableviewcontroller.h" #import "profileobj.h" #import "loginviewcontroller.h" #import "inboxtableviewcontroller.h" #import "profileviewcontroller.h" #import <keychainitemwrapper/keychainitemwrapper.h> @import sdwebimage; @import firebasedatabaseui; @import firebase; @import firebaseauthui; @import firebasegoogleauthui; @import firebasefacebookauthui; - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier; customcell *cell; if(indexpath.row == 0){ cellidentifier = @"cell1"; cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; }else{ cellidentifier = @"cell"; cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; firstorage *storage = [firstorage storage]; firstoragereference *storageref = [[storage reference] child:@"publiclistings"]; if([photo0 intvalue] == 1){ firstoragereference *idref = [storageref child:self.snaps.key]; firstoragereference *folderref = [idref child:@"photos"]; nsstring *filename = @"photo0.jpg"; firstoragereference *imageref = [folderref child:filename]; [imageref downloadurlwithcompletion:^(nsurl *url, nserror *error){ if(error != nil){ nslog(@"%@",error); } else{ [cell.imgphoto sd_setimagewithurl:url placeholderimage:[uiimage imagenamed:@"image3.png"] options:sdwebimagerefreshcached]; // nsstring *url = url.absolutestring; // [cell.imgphoto sd_setimagewithurl:[nsurl urlwithstring:url]]; } }]; } } }
tableviewcell reusable , may dequeued cell has been used, try clear cell state after got cell.
in case, try set
cell.imgphoto = nil;
or
cell.imgphoto = [uiimage imagenamed:@"image3.png"];
before use cell.
Comments
Post a Comment