ios - Dispatch sizeToFit to background -


how dispatch background thread code

-(void)viewdidlayoutsubviews {     [super viewdidlayoutsubviews];     [self adjusttexttoscreen]; }  -(void)adjusttexttoscreen {     //label     [self.detailedcommonlabel sizetofit];     //tablev     cgrect frame = self.detailedcommontablev.frame;     frame.size.height = self.detailedcommontablev.contentsize.height;     self.detailedcommontablev.frame = frame;     self.tableviewheight.constant = self.detailedcommontablev.frame.size.height;     //back scroll height     [self.detailedcommonscrollv setcontentsize:cgsizemake(self.detailedcommonscrollv.contentsize.width, self.detailedcommonimageslider.frame.size.height + self.detailedcommonlabel.frame.size.height + self.detailedcommontablev.frame.size.height + 40)]; } 

properly, because takes long calculating?

i tried different combinations didn't work. sizetofit throws exception must in main thread. realm throws exceptions too.

you can dispatch main thread doing ui stuff on it.

 -(void)viewdidlayoutsubviews {      [super viewdidlayoutsubviews];     dispatch_async(dispatch_get_main_queue(), ^{     [self adjusttexttoscreen];     }); }  -(void)adjusttexttoscreen {           //label         [self.detailedcommonlabel sizetofit];         //tablev         cgrect frame = self.detailedcommontablev.frame;         frame.size.height = self.detailedcommontablev.contentsize.height;         self.detailedcommontablev.frame = frame;         self.tableviewheight.constant = self.detailedcommontablev.frame.size.height;         //back scroll height         [self.detailedcommonscrollv setcontentsize:cgsizemake(self.detailedcommonscrollv.contentsize.width, self.detailedcommonimageslider.frame.size.height + self.detailedcommonlabel.frame.size.height + self.detailedcommontablev.frame.size.height + 40)];    } 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -