I have UIPageViewController
that contains simple UIViewController
s. The View of the VC contains an UIImageView
(aspect fit) at the top and a UITextView at the bottom.
The LayoutConstraints for the ImageView are:
The LayoutConstraints for the ImageView are:
This works as expected.
But when the VC is loaded and has the image to display, I want to change the size of the imageView. There is a minimum and a maximum size and if a image view is smaller or larger it needs to be resized. Otherwise the the imageview has to get the size of the image.
So I calculate the size for the actual image and set the constant for the two LayoutConstraints. The values are correct but the ImageView does not change.
I tried to set them in viewWillLayoutSubviews
but no change.
What am I doing wrong?
Try update your views inside viewDidLayoutSubviews:
- (void) viewDidLayoutSubviews {
// setup your constraints here
}
Hope this helps.