iphoneipadiosadwhirl

iOS Development: How can I preload a view controller before pushing it onto the navigation stack?


I'm diving into iOS development and I'm building a puzzle game to help me become familiar with the platform. I have AdWhirl displaying ads in the score screen that is displayed when the user completes a puzzle. The problem is, it takes at least a few seconds for the score screen view controller to request and receive the ad, in which time the user looks at the score and moves onto a different view. I'm planning to implement an animation that occurs when the user solves a puzzle and the time it takes for the animation to finish would be a good time to request and receive the ad that will be displayed in the next (score) view the user will be taken too.

During the time that the solved-the-puzzle animation is taking place, how can I preload the next view controller so that the ad is present when I push the view controller on to the navigation stack? If this isn't possible, or if it's a bad idea, do you have any suggestions for how I can request and receive the ad while the animation is taking place?

Thanks so much in advance for your wisdom!

Note: For those who aren't familiar with AdWhirl, the process of requesting and receiving an ad is simple. In the viewDidLoad method of the view controller you want the ad to appear in, you create an AdWhirlView (subclass of UIView), add it as subview, and call a method that requests an ad. When the ad arrives, it calls a delegate method to display it in the parent view.


Solution

  • You can call the loadView manually, I don't know if there are any side effect but I don't think so.

    Thanks Tommy, indeed, accessing the view property ensure that loadView will only be effectively called only if the view hierarchy is not loaded yet, avoiding any potentiial leak if the loadView code does note cope with it.