When are views in UIStackViews completely formed?

I have UIPickerView within a vertical StackView, and with various settings for distribution, sometimes the picker looks instrinsic size of 216 high and other times it is ~360 points. I want to overlay a label view (for units) and I want to to center vertically the label. I tried trying to measure the picker height in viewDidLayoutSubviews but the value for the picker's frame isn't close to what I see.


So, the question is, at what point and in what part of the view cycle can I find out the visible height of a view, e.g. picker?

Replies

I'd suggest you try "viewWillAppear" on the relevant view controller. If there are multiple layout passes producing different results, they should all be done by then.

As I trace the view cycle, viewWillAppear actually comes before viewDidLayoutSubviews. At each step, I check for the frame/bounds of the picker and the width/height of the picker is 280,247, and in the simulator it looks and measures much bigger. But when I make a selection from the picker, it goes back to the viewDidLayoutSubviews of the viewController and the width/height is 335,433 (what it looks like).


So, I still have no idea when the height goes from 247 to 433.

Right or wrong, I use a PickerView subclass where I add a labelView calculated to be positioned next to the picker values. I don't add the label until drawRect: and I found that it is the ultimate place to know the completed view and doing the position calculation works.