我有一个 UITabBarController
,其中有 3 个 UIViewControllers
(3 个选项卡)。
当整个 UITabBarController
将消失时,我想从每个 UIViewController
View 中删除特定元素。
有什么办法可以做到这一点吗?我无法在每个 UIViewController
中使用 viewWillDisappear:
因为这会在选项卡更改时删除这些元素。
有什么方法可以将此处理成 viewWillDisappear:
到 TabBarController.m 文件中?
最佳答案
您将引用显示的 viewController。使用后退按钮上的这些引用从您的 Controller 中删除您的特定元素。
希望你能明白。如有任何疑虑,请随时询问?
或者,您可以使用 UINavigationController
的这些委托(delegate)方法:
// Called when the navigation controller shows a new top view controller via a push, pop or setting of the view controller stack.
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
关于ios - 从 TabBar View Controller 中移除 UIElement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21755485/