开发者

UITabBarItem Does Not Dim on First Disabled Load

开发者 https://www.devze.com 2023-01-14 02:34 出处:网络
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 availabl

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 goin开发者_Python百科g through the same procedure does "dim" the disabled tabs...what am I missing?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消