Reputation: 2946
I was thinking of either viewDidLoad
or inside my view subclass in awakeFromNib
(since I load the view from nib). From the design point of view, encapsulating the customisation inside the view subclass sounds better. What are other options?
Upvotes: 1
Views: 81
Reputation: 437917
For me:
If the UI changes require coordination with the app's model, I generally do it in the view controller as I like to think of that as the gatekeeper between the model and the view. If it's creation of controls, I may do it in viewDidLoad
, sometimes viewDidAppear
. If it's re-layout of stuff based upon orientation changes, I'll do it in viewWillLayoutSubviews
.
For anything of complexity that does not require extensive interaction with the model, I'll do in the view subclass.
The obvious other alternative it to design it in Interface Builder (with the appropriate autosizing masks and/or autolayout constraints) so you don't need to do anything programmatically. Often people are doing layout changes based upon orientation or size of the control that could have been taken care of automatically through judicious autosizing settings or autolayout constraints. Clearly this is often not possible, but don't overlook these if you're just adjusting layout based upon the size of the main view.
Upvotes: 1