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
Post a Comment