ios - show spinner and remove it in the same block -


in method can take several seconds have:

uiactivityindicatorview *spinner = [[uiactivityindicatorview alloc]initwithframe:cgrectmake(135,140,50,50)]; spinner.color = [uicolor bluecolor]; [spinner startanimating]; [_mapviewcontroller.view addsubview:spinner];  // lots of code  [spinner removefromsuperview]; 

the spinner doesn't show up. since screen doesn't update @ time. how can around problem?

use gcd:

uiactivityindicatorview *spinner = [[uiactivityindicatorview alloc]initwithframe:cgrectmake(135,140,50,50)]; spinner.color = [uicolor bluecolor]; [spinner startanimating]; [_mapviewcontroller.view addsubview:spinner];  dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{     // lots of code run in background      dispatch_async(dispatch_get_main_queue(), ^{         // stop , remove spinner on main thread when done         [spinner removefromsuperview];     }); }); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -