iphone - How to improve performance while using UIWebView in cells of table view? -
i creating application uses web service.and retrieves list of users , there details images, user id , there names.i displayed information related users in table view, each of cell in table view has image tables in it. using custom cell class create individual cells. selecting row in table presents detail view (using navigation) show larger image , details related particular user selected.
in customcell , detail view class using web view display image. when run app images gets bit of delay display , same happens detail view.
is there alternative can improve performance of table view can have smooth scrolling of table view out delay in image loading , detail view?? here code...
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *customcellidentifier = @"customcellidentifier "; customcell *cell = (customcell *)[tableview dequeuereusablecellwithidentifier: customcellidentifier]; if (cell == nil) { nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"customcell" owner:self options:nil ]; //cell = [[customcell alloc] initwi ]; (id oneobject in nib) if ([oneobject iskindofclass:[customcell class]]) cell = (customcell *)oneobject; } nsuinteger row = [indexpath row]; nsstring *imagename = [imgarray objectatindex:row]; nsstring *completeimageurl = [[nsstring alloc] initwithformat:@"http://122.160.153.166:201/%@", imagename]; nsurl *url = [nsurl urlwithstring:completeimageurl]; //nsurlrequest *requestobj = [nsurlrequest requestwithurl:url]; nsdata *imagedata = [[nsdata alloc] initwithcontentsofurl:url]; uiimage *image = [uiimage imagewithdata:imagedata]; /// check see if getting arrays such image array , userid array , name array of same size.. if(image == nil) { } cell.imgview.image = image; /// other wise execption of out out array range shown [image release]; [imagename release]; //[cell.webview initwithframe:cgrectzero]; //[cell.webview loadrequest:requestobj]; //cell.webview.frame = cgrectmake(20, 0, 80.0, 64); cell.useridlabel.text = (nsstring *)[userid objectatindex:row]; cell.namelabel.text = (nsstring *)[username objectatindex:row]; cell.accessorytype = uitableviewcellaccessorydisclosureindicator; return cell;
}`
i think problem can in imgarray array setting other class. request web service , fetched data users .
any appreciated . in advance
i got same problem. used egoimagecache , thing. find url egoimage
download files names starts "ego", , add project.
and write following code ever want put image:
egoimageview *imgview = [[egoimageview alloc] initwithframe:cgrectmake(50,50,220,360)]; nsstring *imagename = [imgarray objectatindex:row]; nsstring *completeimageurl = [[nsstring alloc] initwithformat:@"http://122.160.153.166:201/%@", imagename]; nsurl *url = [nsurl urlwithstring:completeimageurl]; imgview.imageurl = url; [self.view addsubview:imgview];
thats it. use similar code, ever want image. @ first time while loading take time download image. later cache image , use next time.
Comments
Post a Comment