kinamin
kinamin

Reputation: 127

How to share the ViewController class in TabBar with NavigationController?

Since I am a newbie in iPhone development, I need some advice.
My app has two tabs which

My storyboard layout is,

NavigationController -> tabBarContoller
                        firstTab) tableView ->(segue"showDetail")->(*1 leads to mapView of secondTab) 
                        secondTab) mapView ->(segue"showWeb")-> webView


mapView and webView of each tab shares same class. On storyboard, the segue from tableViewController of first tab leads to mapViewController of second tab.

First tab can show an annotation on mapView, and then show website on webView. Second tab shows annotations on mapView but when I push callout of one annotation, exception throwed that says

'Could not find a navigation controller for segue 'showWeb'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.'

Of course I know I can do with two different implementation of mapview and webview for each tab, but I want to collectively implemented to consider the maintenance.

I think the NavigationController does not function on second tab in this storyboard layout.

Please someone tell me how to do that. Thanks :)

Upvotes: 0

Views: 153

Answers (1)

rdelmar
rdelmar

Reputation: 104092

Your tab bar controller should be the first controller, and the table view and map view controllers should each be embedded in their own navigation controller.

Upvotes: 0

Related Questions