I work with AutoLayout in a storyboard, and everything seemed to be all right. However, when I put one UIView into another and apply all the restrictions that I want to use for both the container and its children, I noticed that the frame is incorrect in viewDidLayoutSubviews:. Instead of being a frame, I would expect it to be calculated taking into account my limitations, this is some disgustingly large frame (albeit in the right origin). For example, instead of the frame {{26, 10}, {444, 10}}, I get something like {{0, 0}, {320, 568}}.
Oddly enough, this only happens with a child UIView when I place it in another UIView, which has some limitations that apply to it with respect to its supervisor (which is a view controller view). Since I have the impression that I can expect my views to be set out correctly in accordance with my limitations in the method viewDidLayoutSubviews:, I am confused why this is happening.
Am I making any wrong assumptions? I would appreciate it if someone would help me point me in the right direction. Thank!
Note. This problem is completely resolved if I perform a setup that depends on the correct frame in viewDidAppear:, but this is a somewhat unsatisfactory workaround for me.
source
share