The TabBarItem disappear when I push in other view - ios

I have a TabBarApplication with four views in the main TabBarItem. The problem comes when I go to any of these views and click in any button to go to another view and when I go back by a button linked to the main view, the TabBarItem of the app disappear!!
For example, one view of the app is a tableView in which each element of the list is linked to his external view and it has a back button that should return to the tableView. All the segues are by modal, not push because push segue crash the application and by modal it runs correctly but the problem comes when I returned by clicking the back button of the NavigationItem in the header of the view to his main view and the TabBarItem of the app is not there, is empty.

Each tab should have the view controller set to a navigation controller, with the view controller you want set as the root view controller of the navigation controller. Now you can use push segues and the standard back button that will be added for you. This will bypass the issue (and work much better for you and users).
You current issue is likely related to not really ever going back. Instead, just always presenting new modal view controllers which replace any existing content on screen.

Related

Losing #IBOutlets after Segue

I'm working with the Xcode view editor and Swift.
I have my main view which contains a tab bar controller with 2 tabs.
On the second tab, I have a #IBoutlet var myLabel: UITextLabel!. Inside viewWillAppear I put some text in this label.
On the first tab, I have a button which launch a third view through a Push segue, and on this new tab, I have a Back button which gets me back to the main view containing a tab bar controller (through a push segue too).
When I launch my app, go in my second tab, the text of the UITextLabel is changed.
I still can go to my first tab and navigate between them it works.
But the problem is when I click on my first tab's button, then on Cancel, then goes back to my second tab, my UITextLabel doesn't change. And I can't perform any action on it anymore. It's not nil though but it's like it's still connected to the first UITextLabel before the segue and not this one.
Where am I wrong ?
Several things are wrong.
With tabbed apps, Apple says that the tab bar controller should be the root level navigation method for the app. It should always be present, and the user should always be able to tap another tap to switch to another part of the app.
So the first tab should connect to a navigation controller. When the user pushes the button, you should push a new view controller onto that navigation controller. The tab bar will still be visible and enabled, and the user will still be able to switch to view controller one.
Next thing:
You say "I have a Back button which gets me back to the main view containing a tab bar controller (through a push segue too)."
That's very wrong. Back buttons should pop a view off of the current navigation stack. They should not be pushing anything. Any time you use a push segue, you are creating and pushing a brand new instance of a view controller, and leaving the other view controllers in the navigation stack.

Launch a viewcontroller in a stack of tabbar controller from background (iOS-Swift)

I have a storyboard with tab bar controller and one of the tabs segue to another view controller and so on as show in the picture.
I want to go to the page (3) programmatically in the stack while maintaining the stack of the tab bar controller .
Thanks in advance..enter image description here
This one's a little tricky, maybe someone else here knows a better way of doing it but here's how I would tackle the problem. Let's assume for simplicity that all views are loaded already. Let me know if this works
Setup an observer in the view controller that is being displayed by the tab selected in the tab bar controller. (Let's call this page TabPageVC). When the event that the TabPageVC is observing is fired have it segue way to page 3 immediately
In app delegate when the app becomes active / enters foreground check to see if you need to display page 3. If you do need to then get the root view controller in app delegate (i'm assuming it's the tab bar view controller, if it's not you'll need to set it to be).
Set the selected tab in the tab bar controller to be the tab of the index that TabPageVC lives in
Trigger that event that TabBarVC is observing this will cause TabBarVC to immediately segue way to page 3 and you'll have retained the stack

I need some clarity on Navigation Controllers

I have a total of 3 views. A menu, the main view where the action happens, and a settings menu.
You can access the settings from both the menu and the main view and go back using the back button provided by the Navigation Controller.
In the main view I have hidden the NavigationBar to free some space, and there's a specific button to go back to the menu. From what I know and have read, I assume this just adds more and more views to the Navigation Stack if I keep going from the main view to the menu again and again, creating a lot of views in the stack.
I'd like someone to tell me whether my assumption is true or not, and evt. explain me the whole process behind navigating and views.
UINavigationController has a property viewControllers which is the stack of view controllers that have been pushed there.
If you use push segues in your storyboard each time you trigger this segues you push the current controller to the stack.
If you have a special logic I suggest you manage controllers programmatically.
This might clear it all.
There are basically following types of Segues to navigate to any viewController
Show (Push)
Show Detail (Replace)
Present Modally
Present as Popover
And to move back use Unwind Segue
You can read more regarding this here

Creating an initial view before displaying views with UITabController

I am creating an app that uses a UITabController with 5 tabs for navigation. Right now my app loads the first tab as the initial view upon app loading.
I want to be able to change that so I have a view that doesn't use my UITabController as the initial view, and once they click the one button on it, it brings them to the First View and displays the TabController.
I thought I'd simply set up a new view, change that one to the initial view controller and have a segue from the button to the TabController, but when I tried that and the view I wanted to with the button loaded first, but when clicking button it said something about needing to set up a NavigationController? Not sure what to do from here.
I think it's best to leave your tab bar controller as the window's root view controller. You can present the initial view controller from the viewDidAppear method of the controller in the first tab, using presentViewController:animated:completion:. Do this with the animated parameter set to NO, and the initial view will be the first thing the user sees. When you're done with that view, just dismiss it, and you'll be back to the first tab's view.

Master-Detail View, Getting a "back" call in the detail view

What I have is a Master view that is embedded in a nav controller and when you push a button it navigates to a different master view and causes a replace segue for the detail view.
What I would like is when the automatic "back button" is pressed, the detail view goes back to the "title" version which I'm using as a splash screen.
Things I've tried so far
Delegating UINavigationBar
Manually forcing a segue when the Master view associated with it's "linked" detailview goes off screen
Okay, figured it out.
Need to get the "splash page" to call the segue. I did do this, BUT I did it with "replace" type, which doesn't allow for "pop" transitions

Resources