Reputation: 1371
I'm new to ios programming so please bear with me:
In the process of trying to familiarize myself with the ios
api, I'm trying to redo a storyboard/xib project programmatically, however I am running into some issues with autolayout constraints.
The project defined some constraint relationships between what I assume to be the the root UIView
of the UIViewController
and its superview
like so:
However, view.superview
returns nil
when I try to reference it in my autolayout
code in viewDidLoad()
.
According to this post, all UIViews have superviews (at the very least, a UIWindow) so this shouldn't be the case? Am I misunderstanding something, or can someone help me figure out where I'm going wrong?
Upvotes: 2
Views: 844
Reputation: 67
viewDidLoad is invoked when the view controller has loaded its view. If you are trying to reference your view in the autolayout module before its parentController view has loaded its view then view.superview will be nil. I can elaborate more if I can see the autolayout code of yours.
Upvotes: 1