grand central dispatch - iOS SetNeedsLayout on thread -


good day,

i have complex calendar control needs redrawn using setneedslayout everytime select date item etc. tried run in gcd block, never ran. however, when run on main thread setneedslayout runs , works. however, causes annoying stutter/lag in program destroys user experience.

can know can done? can executed on thread? can use nstimer or perform selector on thread?

    dispatch_queue_t queue = dispatch_get_global_queue(dispatch_queue_priority_default, 0); dispatch_async(queue, ^{     dispatch_async(dispatch_get_main_queue(), ^{         //[[uiapplication sharedapplication] setnetworkactivityindicatorvisible:yes];     });     @try {         nslog(@"new thread");          if (self.selecteddate) {             [datestoreload addobject:self.selecteddate];         }         if (date) {             [datestoreload addobject:date];         }         self.selecteddate = date;         [self reloaddates:datestoreload];          [self performselectoronmainthread:@selector(reloaddates:) withobject:datestoreload waituntildone:no];         //[self perform]          if (visible && date) {             self.monthshowing = date;         }     }     @catch (nsexception *exception) {         nslog(@"exception = %@", exception);     }     dispatch_async(dispatch_get_main_queue(), ^{         //[[uiapplication sharedapplication] setnetworkactivityindicatorvisible:no];         nslog(@"main thread");     }); }); 

all ui updates need run on main thread, can not change ui background thread (it have unpredictable side effects).

if having performance problems should use instruments profile app find out what's taking processing time , resolve issue (for example, need reload dates , takes significant time?).


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -