iOS viewDidLoad for UIView

ios, uiview, uiviewcontroller

Solution

If you load it from a `XIB` file, the `awakeFromNib` method will be called once loading finishes:

override public func awakeFromNib() {
    super.awakeFromNib();

    // ... loading logic here ...
}

Update; In the case of no XIB, you will probably have to infer it using one of the methods from the Observing View-Related Changes area of the docs (for example, `didMoveToSuperview`). However, a better way is to send a message to your views from the view controller's `viewDidLoad` method if possible.

Problem

In a ViewController, there is `ViewDidLoad` to know when the VC has loaded. For a UIView, what method do i have to use when the view loaded? Would this method be called with any init? edit: No XIB, just programmatically.

Original source

Related problems