views:

466

answers:

1

I use a UIViewController to list out items in 2 separate places. One place is its default home and another is where another controller pushes it onto a nav stack to view a list of items.

Both places allows you to add new items to it by clicking an add button in the navBar. The list's behavior is decided based on a NSObject * called targetController that is set by its caller to its self reference, otherwise it's nil by default.

I ran into an issue where if you had them both showing at the same time in separate tabs of a tabBar the navBar title/rightBarButtonItem would disappear on the one called first. I finally figured out that the navBar was replacing the items stack whenever the list's view was pushed causing the navigationItem to be removed.

My only solution is to force the list's view to be popped whenever a tabBar button item is pressed. Is there a better way?

BTW, I chose to use the same controller in 2 different places to avoid duplicate functionality and thus maintain less code.

A: 

I am pretty sure that popping and pushing views on and off of the navigation stack is exactly the Right way to go about handling switching views, and that if you're tabbing away from the navigation all-together, popping views is probably a good way to keep the memory usage low. Just remember to release them as well.

TahoeWolverine