I have several initially hidden UIPickers in a vertical stack view, where the user chooses one via a segmented controller or a table view elsewhere, and it is unhidden (code below). Visually it works fine - the correct picker appears. But I want to add a subview (a units label) to several of the pickerviews. When I immediately look at the frame of newView in the code below, the frame origin has values as well as the width, but the height is always zero as if the view is still totally collapsed in the stack view. What I need is the height of the picker view to calculate where to put the label subview before it appears.
But paradoxically (to me), the next time around when another picker view is chosen (without the segmented controller around so the picker will be bigger because of AutoLayout constraints), the newView frame for the previous picker appears WITH A HEIGHT and does not reflect the size of the just unhidden picker.
Does anyone know how to find the height of the expanded unhidden picker view before or immediately after it appears?
- (void)showPickerInStackView:(NSUInteger)newPickerIndex {
// hide them all first
for (int i = 0; i < self.pickerStackView.arrangedSubviews.count; i++) {
self.pickerStackView.arrangedSubviews[i].hidden = YES;
}
UIView *newView = self.pickerStackView.arrangedSubviews[newPickerIndex];
newView.hidden = NO;
}