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.