I'm trying to implement an overlay to provide instructions to the user about the other views in an app. Here's a sketch of the view hierarchy:
SomeFullScreenContainerView
FullScreenContainerOfInstructionView
InstructionView
FullScreenView
MaybeSomeIntermediateViews
ViewToProvideInstructionsFor
I need to position InstructionView
relative to ViewToProvideInstructionsFor
, but to do that, I need to be sure that the branch of the view hierarchy containing ViewToProvideInstructionsFor
has been laid out so that I can refer to the frame of ViewToProvideInstructionsFor
to set the frame of InstructionView
. How can I do this?
updated
A few ideas:
FullScreenContainerOfInstructionView
into the view hierarchy after FullScreenView
is completed.[FullScreenContainerOfInstructionView layoutSubviews]
a no-op until you set some flag indicating that FullScreenView
is ready.setNeedsLayout
after FullScreenView
is ready and don't worry about the first pass being incorrect.original
[viewThatNeedsToBeLaidOut layoutIfNeeded];