ios - UITableViewCell label is not updating -


i have seen many posts on here nothing seems working. trying update custom uitableviewcell label setup in storyboard. using code when receive update notification during download:

nsindexpath *index = [self.fetchedresultscontroller indexpathforobject:myobject]; mylisttableviewcell *cell = (mylisttableviewcell *)[self.tableview cellforrowatindexpath:index]; //get update value cell.bottomlabel.text = [nsstring stringwithformat:@"%.1f mb of %.1f mb", megabytesdownloaded, totaldownloadestimate]; 

i can see in logs values correct, , breakpoint on update line hit when should be, label updates when interact cell, or reason,a few seconds after download process has completed.

i using afnetworking , of iboutlets have been checked again , again.

how can update cell in real time?

you calling cellforrowatindexpath outside of tableview reload. either give reused cell or brand new instance not cell shown on screen @ time.

what should call reloadrowsatindexpaths:withrowanimation.

your code should have datasource update trying update cell's bottomlabel.

then code should this:

self.datasource.megabytesdownloaded = megabytesdownloaded; self.datasource.totaldownloadestimate = totaldownloadestimate;  nsindexpath *index = [self.fetchedresultscontroller indexpathforobject:myobject]; [self.tableview reloadrowsatindexpaths:@[index] withrowanimation:uitableviewrowanimationnone]; 

and in cellforrowatindexpath: method, can update cell's bottomlabel @ point.

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     //your normal setup code here     cell.bottomlabel.text = [nsstring stringwithformat:@"%.1f mb of %.1f mb", self.datasource.megabytesdownloaded, self.datasource.totaldownloadestimate]; } 

since looks using afnetworking observe download progress, should throwing view update code on main thread. afnetworking uses multithreading in case prevent jumps or lags in ui. suggest using gcd allow main thread handle updating ui code.

it should this:

dispatch_async(dispatch_get_main_queue(), ^{     //view update code here. }); 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -