Search code examples
objective-cioscocoa-touchadmobiad

Should we call ads in viewDidLoad or viewDidAppear?


We have a tab-heavy app, which has 5 tabs to use back and forth. We have iAds and admobs(as backup for countries without iAd), and we 'call' the ads in viewDidLoad. Would it make a difference to call them in viewDidAppear instead? And then remove them in viewDidDisappear or shomething not to screw up the frames etc? Would this give more impressions etc?


Solution

  • viewDidLoad:

    viewDidLoad Called after the controller’s view is loaded into memory.

    - (void)viewDidLoad
    

    Discussion This method is called after the view controller has loaded its view hierarchy into memory. This method is called regardless of whether the view hierarchy was loaded from a nib file or created programmatically in the loadView method. You usually override this method to perform additional initialization on views that were loaded from nib files.


    viewDidAppear:

    viewDidAppear: Notifies the view controller that its view was added to a view hierarchy.

    - (void)viewDidAppear:(BOOL)animated  
    

    Parameters animated If YES, the view was added to the window using an animation. Discussion You can override this method to perform additional tasks associated with presenting the view. If you override this method, you must call super at some point in your implementation.

    Answering

    So viewDidLoad is called slightly earlier than viewDidAppear: , the only difference is that when viewDidAppear: the view have been already drawn, instead in viewDidLoad the view has still to be drawn.

    So answering to your questions:

    Would it make a difference to call them in viewDidAppear instead?

    If calling the ads is a slow operation, then you would see first the view appearing in it's color, and the ads after a few interval of time.However this has to be too slow to make a real difference.

    And then remove them in viewDidDisappear or shomething not to screw up the frames etc?

    It doesn't "screw up frames", that for sure.