Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top