ios - Activity Indicator doesn't stop in the same method -


in method viewdidload initialize activityindicatorview.then, in following method sent activity indicator start. when start app , runs if statement, activity indicator starts, when operations in dispatch queue performed, activityindicator not stopped. here method:

-(void) tableview:(uitableview *)tableview willdisplaycell:(uitableviewcell *)cell forrowatindexpath:(nsindexpath *)indexpath {      if([indexpath row] == [_myarray count]-2){          [_activityindicator startanimating];          dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_background, 0), ^{              //here perform operations              [self.tableview reloaddata];              [_activityindicator stopanimating];         });     } } 

i wish activity indicator stopped after execution of operations in dispatch queue!

you should perform ui operations on main thread. try refactor:

dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_background, 0), ^{      //here perform operations      dispatch_async(dispatch_get_main_queue(), ^{         [self.tableview reloaddata];          [_activityindicator stopanimating];      }); }); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -