Search code examples
iosuitabbarcontrolleriad

How does the TabBarController stay always visible?


I have been trying to find why the TabBarController is always visible. I have been trying to implement an iAd that doesn't reload every time I change View Controllers. I was able to implement this with an app that uses TabBarController, by appending the iAd to the TabBar, however, I another app that doesn't use the tabBarController I want to do the same thing, and I have not found a way to implement this. I have found several suggestions, here and there, but they are all, either, very complicated or don't work.


Solution

  • TabBarController is somewhat the container of all the other UIViewControllers. Everything is happening inside it. UINavigationController behaves the same.

    In order for a UIView to be visible on all other UIViewControllers you can:

    1. Create your app inside a UIView Container and add the persistent UIView to that container

    2. Add your UIView as a subview of UINavigationController view

    In your first UIViewController:

    UIView *myView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
    myView.backgroundColor = [UIColor purpleColor];
    [self.navigationController.view addSubview:myView];