11
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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
8
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
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?