Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 729
Sti Avatar asked Nov 26 '25 18:11

Sti


1 Answers

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.

like image 134
Ramy Al Zuhouri Avatar answered Nov 28 '25 09:11

Ramy Al Zuhouri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!