TabBarController 如何保持始终可见?

How does the TabBarController stay always visible?

我一直在寻找为什么 TabBarController 总是可见的原因。我一直在尝试实现每次更改视图控制器时都不会重新加载的 iAd。通过将 iAd 附加到 TabBar,我能够使用使用 TabBarController 的应用程序来实现这一点,但是,我另一个不使用 tabBarController 的应用程序我想做同样的事情,但我还没有找到实现的方法这个。我在这里和那里找到了几个建议,但它们要么非常复杂,要么不起作用。

TabBarController 在某种程度上是所有其他 UIViewController 的容器。一切都在里面发生。 UINavigationController 表现相同。

为了让 UIView 在所有其他 UIViewController 上可见,您可以:

  1. UIView Container 中创建您的应用程序并将持久性 UIView 添加到该容器

  2. 将您的 UIView 添加为 UINavigationController 视图的子视图

在你的第一个 UIViewController:

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