1

I'm using version 1.1 of the Three20 library and I'm setting a global style sheet to change the navigationBarTintColor in my app delegate like this:

[TTStyleSheet setGlobalStyleSheet:
  [[[DefaultStyleSheet alloc] init] autorelease]];

That is working just fine, except when my app state is restored by calling restoreViewControllers in TTNavigator. In that case, the navigation bar is showing the iOS default, pale blue color. When I navigate on to the next view, the style sheet takes effect again.

I also posted this question on the Three20 Google Group. I'll update here if I find an answer there, of course.

cg.
  • 3,648
  • 2
  • 26
  • 30
  • I thought there used to be a way to answer your own questions, but I can't find it right now. Probably missing something obvious... In the mean time, if someone is looking for a solution to this, you'll find the answer here: http://groups.google.com/group/three20/browse_thread/thread/affbd2a0ee2851c8 – cg. Mar 24 '11 at 15:08
  • Never mind, I just found the button... – cg. Mar 24 '11 at 15:10

1 Answers1

1

In the mean time, I found a solution to this with the help of the kind people on the Three20 Google Group.

In short: The global style sheet will work correctly, if all view controllers descend from TTViewController. When inheriting directly from UIViewController, a work-around is needed to enforce the wanted behavior. Use either categories or a common super-class to implement the following method for your view controllers:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    // Work-around for Three20 style sheet misbehavior. See:
    //  http://groups.google.com/group/three20/browse_thread/thread/affbd2a0ee2851c8
    //  http://stackoverflow.com/questions/5406827/ttstylesheet-not-workin-when-restored-by-ttnavigator
    if (self.navigationController) {
        self.navigationController.navigationBar.tintColor = TTSTYLEVAR(navigationBarTintColor);
    }
}
cg.
  • 3,648
  • 2
  • 26
  • 30