I'm creating a UIViewController subclass, and I create it with a custom init function, initWithImages:(NSArray *)images, that then returns the view controller for use.
I'm confused however what I'm supposed to do in the init versus the viewDidLoad, viewWillAppear, etc. functions. In this init function I set up the image view, a caption label and give it gesture recognizers, but are those things that should only be done when it loads or appears?
Should the init be as small as possible? What do I put in each is basically my question?
I'm using the UIViewControllers with a UIPageViewController so it's important that even with a bunch of view controllers in the page view controller that memory isn't used absurdly, so I want to make sure I'm doing this right.
init should be used for data related basic initialisation. viewDidLoad Should be used for view based initialisation, because the view has been created at that point in time so you can add subviews. There is no point creating subviews if you can't use them yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With