I am adding a view programatically and changing constant of height constraint but it does not set the width as the screen width in viewDidLoad method. But width perfectly set when put those line in after 0.2 seconds delay queue.
Below is my Code
Added In ViewDidLoad
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
cAreaView = [[[NSBundle mainBundle] loadNibNamed:@"aView" owner:nil options:nil] objectAtIndex:0];
[_vwComplaintArea addSubview:cAreaView];
[self setConstraintLayout:cAreaView toVw:_vwComplaintArea];
[_firstViewHeightConstraint setConstant:_firstViewHeightConstraint.constant + cAreaView.bounds.size.height];
[_heightForComplaintARe setConstant:cAreaView.bounds.size.height];
});
-(void)setConstraintLayout:(UIView *)vw toVw:(UIView *)toVw
{
[vw autoSetDimensionsToSize:CGSizeMake(toVw.bounds.size.width, vw.bounds.size.height)];
[vw autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:toVw];
[vw autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:toVw];
}
Can anyone suggest the best way to set constraints programatically in viewDidLoad.
Thanks.