objective c - When do the iOS autolayout interface constraints get executed? -


in view there seems delay between viewdidappear being called , constraints of interface elements being executed.

i have uilabel size changes according content. if check constraints in viewdidappear, they're empty. if wait 500ms (for example) , check again, constraints there expect them be. same goes bounds of uilabel, no use , then, once constraints have kicked in, they're set expect.

my code:

- (void) viewdidappear:(bool)animated {     [super viewdidappear:animated];      // constraints , bounds     nslog(@"description constraints %@", [descriptionlabel constraints]);     nslog(@"description bounds %@", nsstringfromcgrect([descriptionlabel bounds]));      // wait bit, constraints     double delayinseconds = 0.5;     dispatch_time_t poptime = dispatch_time(dispatch_time_now, (int64_t)(delayinseconds * nsec_per_sec));     dispatch_after(poptime, dispatch_get_main_queue(), ^(void) {         nslog(@"description constraints b %@", [descriptionlabel constraints]);         nslog(@"description bounds b %@", nsstringfromcgrect([descriptionlabel bounds]));     }); } 

and output code:

10:39:35.949 abc[2550:949660 constraints ( ) 10:39:35.950 abc[2550:949660 bounds {{0, 0}, {42, 21}}  10:39:36.480 abc[2550:949660 constraints b (     "<nscontentsizelayoutconstraint:0x175c0310 h:[uilabel:0x176d5080'elit ipsum amet ut cillum...'(290)] hug:251 compressionresistance:750>",     "<nscontentsizelayoutconstraint:0x175c0350 v:[uilabel:0x176d5080'elit ipsum amet ut cillum...'(629)] hug:251 compressionresistance:750>" ) 10:39:36.482 abc[2550:949660] description bounds b {{0, 0}, {290, 629}} 

the {42, 21} interface builder , arbitrary because constraints change size whatever content demands.

i'm using xcode 6.1, targeting ios 7.1, running app on ipod touch running ios 8.1.

-(void)viewdidlayoutsubviews 

for view controllers and

-(void)layoutsubviews 

after calling

[super layoutsubviews]; 

for views.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -