2
votes

I am changing my app to use UITabBarController instead of UINavigationViewController. I replaced controllers accordingly and app launches with tabs successfully. Later in the code I came across some difficulties using segues where lines like

[self performSegueWithIdentifier:@"ImageViewController" sender:self];

won't work producing error

"Push segues can only be used when the source controller is managed by an instance of UINavigationController"

When I embedded UINavigationController into the initial FirstViewController, line above worked fine. I need that line to switch between views and pass some data to another view controller.

The problem is that using segue identifier to go to SecondViewController hides TabBar navigation (unless I wrap SecondViewController in UINavigationController again and so on). That is not the solution.

Question: How to use UITabBarController and still take advantage of segues while keeping tab navigation visible?

enter image description here

2

2 Answers

2
votes

"Push segues can only be used when the source controller is managed by an instance of UINavigationController"

Sounds to me like you are using a push segue somewhere outside a navigation controller. Try to select all "segue bubbles" in interface builder that are not inside a navigation controller:

Segue Bubble

and check the segue's style in the right pane:

Segue Settings

If the style is set to the value push as shown above change it to modal or custom:

Change style to Modal

1
votes

There is something wrong with your connections. If you are using interface builder (storyboard) then your connections should look like this. See pic

Notice you are missing UINavigation Title headers. Also the gray area below on each view controller means that space is reserved for images for UITabBarController

Another problem is your UIToolBar. Looks like its sitting on top of where UITabBar will be displayed. That may/may not get your app rejected by apple since you already have a UINavigationController and UITabBarController. If you need more buttons/options on that page make them UIButtons instead.

enter image description here