gpt4 book ai didi

iphone - TTNavigator 恢复时,TTStyleSheet 不工作

转载 作者:行者123 更新时间:2023-11-29 13:49:43 26 4
gpt4 key购买 nike

我正在使用 Three20 库的 1.1 版,我正在设置一个全局样式表来更改我的应用委托(delegate)中的 navigationBarTintColor,如下所示:

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

工作正常,除非我的应用程序状态通过调用 TTNavigator 中的 restoreViewControllers 恢复。在这种情况下,导航栏会显示 iOS 默认的淡蓝色。当我导航到下一个 View 时,样式表再次生效。

我还在 Three20 Google Group 上发布了这个问题。当然,如果我在那里找到答案,我会在这里更新。

最佳答案

与此同时,我在Three20 Google Group上的好心人的帮助下找到了解决这个问题的方法。 .

简而言之:如果所有 View Controller 都来自 TTViewController,则全局样式表将正常工作。当直接从 UIViewController 继承时,需要一个变通方法来执行想要的行为。使用类别或通用父类(super class)为您的 View Controller 实现以下方法:

- (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);
}
}

关于iphone - TTNavigator 恢复时,TTStyleSheet 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5406827/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com