Search code examples
iosiphoneobjective-cxcodeuiscrollview

Delegate when constraints updated


I am facing an issue while using storyboard auto layout with UIScrollView. I am updating a constraint of a UIScrollView, and after that setting the content size of scrollview. But UIScrollView constraint takes a bit of time to update and initially UIScrollView is not able to scroll because of more height than a view. I can not change the current implementation.

Is there any way, notification or any delegate method to check that the constraints are updated, so that I can do further changes?

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *scrollViewHieghtConstraint;

self.scrollViewHieghtConstraint.constant = 500;
[self.scrollView updateConstraints];

[self.scrollView setContentSize:CGSizeMake(0, 1000)];

Solution

  • You can use - (void)updateViewConstraints selector of UIViewController.

    You can also use - (void)updateConstraints selector of UIView if you have extended said view.