I'm trying to work around an issue I'm having using the interface builder to handle constraints. So I decided to do them programmatically. My problem though is one of my UI elements has a null superview at like every point I can think of to set the constraints, and so will throw an exception. I have 2 elements added via IB: a UITextField and a UITableView. In ViewDidLoad, the text field has its superview defined but the table does not. I've tried ViewWillAppear, ViewWillLayoutSubviews, ViewDidLayoutSubviews, UpdateViewConstraints, and it's all the same: the table's superview is null, the text field's isn't. It does eventually get set: I set a breakpoint in ViewDidAppear and now superview isn't null. But setting the constraints at this point does nothing. From what I've read, here:
I should be setting them in ViewDidLoad. I don't understand why the superview is null. I've tried deleting the table and just adding a basic unmodified label at the center of the main view: this label also did not have its superview set, just like the table, but the text field did.
When should I be programmatically setting constraints so that I can be assured that the superview of whatever I'm targeting isn't null? Thanks.