English 中文(简体)
UINavigationBar color changes unexpectedly
原标题:

In my current UINavigationController, the viewControllers stack looks like this. 1 -> 2 -> 3. Before transitioning from the 2nd to the 3rd controller however, I pop the 2nd one first so that when the 3rd controller is popped, the 1st controller is on top.

[self.navigationController popViewControllerAnimated:NO];
[self.navigationController pushViewController:controller animated:YES ] ;

But somehow doing this changes the navigationBar s color from the original blue default to the black style. Explicitly setting the barStyle to UIBarStyleDefault in the new controller s viewWillAppear or viewWillDisappear has no effect. What s stranger, if I set the barStyle at all, even the 1 -> 2 transition will cause the bar color to change to black.

By the end of writing this post, I realized that the following code fixed it.

navBar.barStyle = UIBarStyleDefault-1;

Why would I need to subtract 1 from the default to actually obtain the default color?

问题回答

I faced the same problem as well. I don t have a formal answer but I fixed it in my way:

-(void)viewWillAppear:(BOOL)animated { 
UIColor *navColor = [[UIColor alloc]initWithRed:0.742778 green:0.0181208 blue:0.0271147 alpha:1];
[self.navigationController.navigationBar setTintColor:navColor];}

I wish someone could propose a better answer.

I would not pop the second, just push the 3rd. And when you dismiss the 3rd use

[self.parentViewController.parentViewController popViewControllerAnimated:YES];

This for me reaches back and cleans up the stack and leaves me on controller 1 without showing controller 2, with all normal attributes.





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签