5

I wasn't lucky with searching for this, so here we go ;)

I have a UIViewController with a custom UINavigationBar which pushes another UIViewController as subview.

Everything works fine except when I click the back button on the subview. The previews (first) view appears correctly, but not animated. The animation of the UINavigationBar is correct, only the views switch immediately.

The function - (void)viewWillAppear:(BOOL)animated of the first UIViewController gets called with NO for animated. This only happens when I test with iOS 5, not with iOS 4.

Does anyone know how to fix this?

Thanks for your help! Hannes

UPDATE 1

I just removed all custom code and just used the plain UINavigationBar (so no extra settings) and it still doesn't work with iOS 5. This is my code I use in the first ViewController to push the second ViewController:

[self.navigationController pushViewController:secondViewController animated:YES];

As I already mentioned - when I click the back button in the navigation bar on the second view the first view appears immediately without animation.

Any help would be appreciated! Thanks!

UPDATE 2

I feel like I'm getting closer to the issue, but still no solution:

I just added a custom UINavigationController where I just call [super popViewControllerAnimated:animated]. This get's called correctly (animated is YES) but the viewWillAppear of the first UIViewController gets NO as value for animated...

0

3 Answers 3

6

I was having a similar problem today where the UIViewController was getting NO in viewWillAppear, except with the standard UINavigationBar and UINavigationController.

It turned out to be due to manually calling viewWillAppear:YES somewhere it shouldn't have been. This item suggests that it can also be caused by calling the wrong super method somewhere (e.g. [super viewWillAppear:animated] instead of [super viewDidAppear:animated] inside of viewDidAppear).

As for using a custom UINavigationBar, I ran across this link today that may help your case: http://sloshire1.posterous.com/simple-fix-for-viewwillappear-in-ios5

3
  • 2
    oh my god, thank you sooomuch!! i was going nuts with this one! i just discovered that there was a [super viewWillAppear] in the viewDidAppear of my custom UITabBarController. Thanks again!
    – Hannes
    Jan 20, 2012 at 22:16
  • @Hannes thanks it works for me @Hannes are you using Rumex CustomTabbar(RXCustom Tabbar) i have just hide the [super viewWillAppear] in the viewDidAppear of my custom UITabBarController. is this creates any problem? what was problem with this.? Jul 17, 2012 at 10:42
  • @Hannes i am opening present modal viewcontroller at that time i am getting same problem. do you have any idea? Jul 17, 2012 at 10:45
0

Apple implemented official ways to create custom navigation bars in iOS 5. Unfortunately, they also broke most of the non-official ways of doing it in iOS 4. iOS 5 won't call drawRect for you anymore. You need to have two ways of doing it, one for iOS 5 and greater, using the new calls, and one for iOS 4 and earlier, using the old calls. Check out the documentation for custom navigation bars in iOS 5 for more info.

1
  • Hi Owen, thank's for getting into this. I subclassed UINavigationBar and linked it in the .xib file to get a custom header - it works for iOS 4 and 5. Nevertheless I just removed the custom UINavigationBar and just the regular bar and still the same effect, the views animate correctly when showing the subview but switch immediately when clicking the back button.
    – Hannes
    Jan 17, 2012 at 22:36
0

Did you try to remove all your custom code and go with the native navigation bar? Does the behavior stay the same? This way you can check if your custom bar messes with the transition.

1
  • Thanks, I just did that but still the first view appears without animation... I updated my question.
    – Hannes
    Jan 20, 2012 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.