LoginSignup
11
9

More than 3 years have passed since last update.

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

Last updated at Posted at 2018-06-06

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

11
9
0

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
  3. You can use dark theme
What you can do with signing up
11
9