Reputation: 133
i have two UITableViewController´s "Flowers" and "Trees". If you select a specific flower or tree some detail information will be presented. So that´s the standard behavior as everybody knows. What i want to achieve is the following:
These UITableViewControllers should be managed by one UINavigationController and the user should be able to select them via a UISegmentedControll which is placed in the Header of the UINavigationController. So the user can switch between the UITableViewControllers by interacting with the UISegmentedControl. If the user selects one specific flower or tree the detail information should be presented and the UISegementedControl should be replaced with a back button.
Is this possible and how can i achieve this? If its not clear i can try paint some pictures :-)
Thank you Christian
Upvotes: 0
Views: 269
Reputation: 62686
It's doable, notwithstanding whether it's advisable. The VCs in a navigation controller are not peers - one must be the root, the others must be pushed and popped atop it. So you could do this:
You'll probably want to hide the back button on VC2.
About advisability: I'd want to have a good reason for doing this instead of the standard pattern. Is it the slide animation on transitions? That could be created without the nav vc. Is it the idea of having each segment present a view controller instead of a view? A case could be made that the nav vc is a good, already built container vc, and using it would save you some trouble. It's highly unlikely that any of this gets your app rejected by Apple, IMO.
Upvotes: 0
Reputation: 131398
That's not how navigation controllers work. A navigation controller manages a stack of view controllers. Having a segmented controller in the navigation bar and having it somehow switch between child view controllers - if you could make it work - goes against Apple's Human Interface Guidelines. Apple would likely reject your app if you did make it work.
What you describe is more like a tab bar controller. I developed an app prototype for a client that used a parent view controller that was a variation on a tab bar controller that had a segmented control on the bottom that did what you describe.
You could build your own custom parent view controller that does what you describe, but you should NOT try to make it shuffle the stack of view controllers in a navigation controller.
Upvotes: 1