문제

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.

도움이 되었습니까?

해결책

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);
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top