What similar functionality method (viewWillAppear) exists on UIView?

前端 未结 3 581
星月不相逢
星月不相逢 2021-02-06 23:36

viewWillAppear is called on UIViewController when a view is about to be shown on screen. Is it possible to get similar callback on UIView?

3条回答
  •  长发绾君心
    2021-02-06 23:53

    How about the following from the UIView reference

    willMoveToSuperview:, didMoveToSuperview - Implement these methods as needed to track the movement of the current view in your view hierarchy.

    this will at least tell you when it is added to a view hierarchy but there is no guarantee that the view hierarchy is presented/viewable.

提交回复
热议问题