search
LoginSignup
8

More than 3 years have passed since last update.

posted at

updated at

addChild(_:), addSubview(_:)のあとは、didMove(toParent:)を呼びましょう

addSubViewまでで良いと思っていた……。知らなかった。

// UIViewControllerのクラスで
addChild(someViewController)
view.addSubview(someViewController.view!)
someViewController.didMove(toParent: self)

(参考)
https://www.slideshare.net/asakahara/container-viewcontroller
https://qiita.com/yimajo/items/a5e16fa0f9c332a55ccf
https://qiita.com/edo_m18/items/8b6b457f82b185ab1f6a

(追記)
ちゃんとドキュメントに書いてあるので、読んでおくべし。。。
didMove(toParent:) - UIViewController | Apple Developer Documentation

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
8