views:

311

answers:

2

Hi there, i have an app that uses a navbar. What i want to acomplish is make it transparent when i push in the last view from the nav sequence, and make it opaque when i click the back button on the nav

i tried with on dealoc, but it doesn't work. My view is an UIScrollView not an UiView, but i guess that makes no difference.

As i see it, eighter i have to control the events on the nav bar, and see the type of the view with a loop or trigger some event on the "unloading" of my current view

when i push in the view i do a self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

and when it pops out i need the

self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;

A: 

You can't really depend on dealloc to ever get called, much less when you want it. That should only be used to release retained objects.

I think you should be able to add the barStyle changes in the viewDidAppear and viewDidUDisappear methods of your view controller.

Nimrod
+1  A: 

Pushing and popping a view with UINavigationController or UITabController will call the view {Will,Did}{Appear,Disappear} methods so I think you need to hook into the child view's ViewWillDisappear.

I'd architect it so that top level navigation controller sets itself as the childs delegate, and the child calls its delgate with an "I'm unloading" type function where you change the navbar style.

Andiih