UIAppearance图像第一次没有加载

时间:2013-12-28 12:53:36

标签: ios7 uinavigationcontroller uibarbuttonitem uiappearance

我刚刚开始将UIAppearance添加到我的项目中并遇到UIBarButtonItems

- (void)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]} forState:UIControlStateNormal];
    [[UIBarButtonItem appearance] setBackButtonBackgroundImage:[[UIImage imageNamed:@"UIBarButtonItemBack"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 2, 0, 13)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[JWViewController alloc] initWithNibNam:@"JWViewcontroller" bundle:nil]];
    [self.window makeKeyAndVisible];
    return YES;
}

当我打开应用程序并单击tableViewCell时,navigationController会推送到另一个viewController并显示一个带有白色文本颜色且没有背景图像的后退按钮。当我按下按钮时,会出现背景图像,然后当我取消触摸时,它就在那里。当我实际返回然后再次进入第二个视图时,它也会出现。

这是iOS 7上的一个已知问题,还是可以想象它有什么问题?

1 个答案:

答案 0 :(得分:0)

这里的问题相同。似乎调用setNeedsDisplay显然可以解决问题。

我将这些行添加到我需要修复的视图控制器的viewWillAppear / viewDidLoad(etc)中:

dispatch_async(dispatch_get_main_queue(), ^{
    [[self.navigationController.navigationBar subviews] makeObjectsPerformSelector:@selector(setNeedsDisplay)];
});
相关问题