How do I jump to say, the second view controller in my navigation controller at app launch? - ios

Like many apps, I have a main screen in my app that I want the app to launch to, but they also have the option of going back a screen to somewhat of a "home" view. I don't want to present this modally, as it is technically "before" the view controller they launch at.
So if my navigation controller has this first "home" view controller, then the "main" view controller after that (then some others after that...) how do I start the app at the second, main view controller and still allow them to easily press back to go home?
I tried setting my "Initial view controller" in my Storyboard to the second one, but it doesn't seem to work as it doesn't show the navigation bar and seemingly won't allow you to go back.

I'd recommend setting the "home" view controller as the "Initial view controller", but then segueing to the "main" view controller in the viewDidLoad or viewWillAppear of your "home" view controller; that way, unlike in Mike's answer, you can dismiss that "main" view and go back to the "home" view before it such that it's the only view controller on the stack.

You should make the second viewController the initial view, then make a UIBarButton on the second viewController, to let the user go back.

Related

Set initial view controller of a navigation controller

I'm developing a simple iOS app to learn Swift and iOS programming.
I was wondering what would be the "best" way to present, on app launch, a different View Controller than the first one in the Navigation Controller stack.
Consider this storyboard diagram:
The Tab Bar Controller is the initial View controller and "View Controller 1" is shown at app launch inside the navigation controller. Since "View Controller 1" will be almost never used, I'd like to show "View Controller 2" instead, with the "back" button pointing to "View Controller 1". To save time and memory, I'd prefer non to load "View Controller 1" at all, since I already know what data has to be shown in the second view controller.
Both the view controllers are actually Table View Controllers and the selection of one of the cells in the first VC triggers a segue to the second. However the user would usually only need to see the second VC as if the first cell of TVC 1 was selected.
Because you want to be able to "go back" to the first VC, it needs to be put below the second one. My suggestion is to programatically set up the first VC as the root view controller in appDelegate didFinishLaunchingWithOptions and immediately push/present VC2. In this way the first VC won't be shown and therefore costly views loading/laying out subviews can be omitted.

The TabBarItem disappear when I push in other view

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.

Issue with tab and navigation view controller

I have an iOS app which is structured in this way:
One tab bar controller with 4 navigation controllers. Each navigation controller has its own view controller with a xib file.
The issue, is that ONLY THE FIRST TIME, when I push a new view into one of the navigation controllers, the new view doesn't appear at all. When I switch to another nav controller (touching one of tab bar's options) and then switch back to the first one, it works all the time.
The error I'm getting is when I come back is:
[35731:70b] Unbalanced calls to begin/end appearance transitions for
.
Thanks for helping out.
Make sure you are presenting all your view controllers from the parent / top level view controller (the tab bar controller). I've had this a few times when presenting a view controller from one of the view controllers in the tab bar.
In viewdidload assign your first view controller to load when xib loads. Its the correct way to load first view controller to appear when nib loads.

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