ios - 从 TabBar View Controller 中移除 UIElement

标签 ios objective-c uiviewcontroller uitabbarcontroller

我有一个 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/

相关文章:

ios - 尝试在 Xcode 中打印对象描述会产生错误

ios - 如何设置关联域/通用链接

ios - 与 iOS 中的 setter/getter 相关的奇怪的 EXC_BAD_ACCESS 崩溃

iphone - Objective-C/iPhone IRC 库

objective-c - 具有 subview 和多个 NIB 的核心数据绑定(bind)

iphone - 优化 objective-c 代码以访问联系人

ios - 如果 View Controller 由于内存不足而被卸载,那么当它即将再次显示时,loadView 是否会再次被调用?

objective-c - 控制声音的速度xcode

ios - 在应用程序启动时呈现不同的 UIViewController

ios - 完全删除 View Controller - Swift