UITabBarItem 在第一次禁用加载时不会变暗

发布于 2024-09-16 09:47:26 字数 405 浏览 2 评论 0原文

我可以轻松启用和禁用我的应用程序中没有值或内容的 TabBarItems。就像魅力一样。我确实想保留所有选项卡,以便表明此功能或内容将在整个应用程序的其他视图上可用,因为此特殊视图动态填充内容超过 30 次。

TabBarController 是我的“DetailViewController”中的子类。在此类中,我确实检查是否存在任何内容,并通过传递 viewWillAppear 事件来延迟加载内容(防止加载不存在的选项卡内容并检查互联网连接等)。工作又快又好。

问题更多的是设计光学问题。第一次加载视图可以启用和禁用,但图片不会“变暗”。加载第二个视图并执行相同的过程会“变暗”禁用的选项卡...我错过了什么?

I can easily enable and disable the TabBarItems in my App which have no values or content. Works like a charm. I do want to keep all Tabs in order to show that this feature or content will be available on other views throughout the App because this special view is dynamically filled with content over 30times.

The TabBarController is subclassed in my "DetailViewController". Within this class I do check if any content exists and lazy-load the contents by passing on the viewWillAppear event (preventing loading non existing tab contents and checking for internet connections etc.). Works fast and good.

The problem is much more an design optical one. Loading the views the first time enabling and disabling works, but the pictures are not "dimmed". Loading the second view and going through the same procedure does "dim" the disabled tabs...what am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

草莓酥 2024-09-23 09:47:26

在对 self 调用 viewWillAppear 之前我会三思而后行,因为结果可能是不可预测的。

// BAD IDEA
- (void)viewDidLoad {
    ...
    [self viewWillAppear];
    ...
}

// OK
- (void)viewWillAppear {
    ...
    [super viewWillAppear];
    ...
}

...例外是您从同名方法中调用 [super viewWillAppear]。

一般来说,最好将 Apple 回调的触发留给 Apple 处理。尝试重构 viewWillAppear 中的功能,然后在 viewDidLoad、viewWillAppear 和 viewDidAppear 中调用所需的功能。当您分解每一个功能时,问题很可能会出现。

I'd think twice before calling viewWillAppear on self as the results can be unpredictable.

// BAD IDEA
- (void)viewDidLoad {
    ...
    [self viewWillAppear];
    ...
}

// OK
- (void)viewWillAppear {
    ...
    [super viewWillAppear];
    ...
}

...the exception being your call to [super viewWillAppear] from within the same-named method.

In general, it's best to leave the firing of Apple's callbacks to Apple. Try refactoring out the functionality you've got in viewWillAppear and then call just what you need in viewDidLoad, viewWillAppear, and viewDidAppear. The problem is likely to emerge as you break out each bit of functionality.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文