It might be because you're not calling sub.didMove(toParent:)
Topic:
UI Frameworks
SubTopic:
UIKit
Tags: