开发者

Iphone UINavigationController onchange event

i h开发者_如何学Pythonave 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;


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.


Actually the best way for this is to use UINavigationControllerDelegate. I extended UINAvigationController and set the delegate to self and used one of the methods of the UINavigationControllerDelegate protocol.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜