views:

27

answers:

1

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?

A: 

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.

clozach
May be my description was a bit confusing concerning the event structure. I do fire the events in the same events at this point. Reviewing my code I found that your hint has some importance to my implementation of the RootViewController. I 'load' an UITabBarController within my RootViewController by switching the view and firing the events directly afterwards and here we are, the chain may break here. Seems I should redo this part completely in order to stay with the SDK Guides and implement my ToolBar by myself. This should avoid (hope so) the effect. Thx.
mic
Ok, thx again clozach, it wasn't the direct answer, but the hint I needed. Did some recoding over the night and introduced the correct controller layer. MVC does work, if you do MVC ;).
mic