I’m just getting back into iOS development after a year or so away and am looking for a way to have a single view above or below a UITabViewController view. The idea is to have one ad view that is used throughout the app instead of one on each tab. The constant reinitializing of the ad view seems like it would be a lot of overhead so having one persist throughout would seem to be more effective.
I’ve searched for this but not found much of anything so even a useful link would be appreciated.
Thanks in advance,
Jason
I see several approaches here:
Since you are setting up your view hierarchy in your application’s delegate, I’d suggest creating a separate
UIViewControllerand managing it from your app delegate. That way you can show/hide it in the main UIWindow, without having to do much work.You can subclass
UITabBarControllerand show the ad in the visible view controller. This is more work, but your app architecture is arguably cleaner, because your app delegate doesn’t get cluttered with ad-related code.Another option is to look into a
UIViewControllercategory, where you can manage add related code. Not necessarily the cleanest, but it keeps the ads out of both your app delegate, and your tab bar controller. (You’d add the ad view as a category property via runtime level calls and associate objects, but that gets messy.)I’d probably go with the first approach if it were me, but I could argue for either of the other two approaches, since an ad view doesn’t really necessitate it’s own view controller.