Pushing from Tabbar Storyboard to another Storyboard issue - ios

Here are my storyBoards
Tabbar Storyboar
other storyboard
here is my code to Move TabbarStoryBoard to Other Storyboard
let storyboard = UIStoryboard(name: "Tabbar", bundle: Bundle.main)
let vc = storyboard.instantiateViewController(withIdentifier: "LoginController") as? LoginController
self.navigationController?.pushViewController(vc!, animated: true)
Now when I move from Tabbar StoryBoard from Other storyboard's LoginController, and signIn with email & password and want to redirect user to Tabbar storyboard is not pushing. It is successfully pushing from Tabbar storyboard to other storyboard's view controller, even it is not pushing in same storyboard to other viewcontroller
It is not giving any error, and also not pushing to Tabbar Storyboard.
What is my issue?
Note : Tabbar Storyboard's TabbarViewcontroller is my initial viewController

Story Board Referencing is the best thing for this... Hope these links will work.
Use Storyboard References While Retaining Icons & Text for Tab Bar Controller
How to add storyboard reference in another storyboard

Related

Add tab bar for all the screens iOS(swift)

I am working with UISplitViewController. I have UISplitViewController which contain UITabBarController. So I want to display tab bar in all the screen through out the application (Even in detail screen of UISplitViewController for iPhone). Please see the approach:
use segue to move from one controller to another controller or move via navigation so in the next controller your tabbar will be show
just like if u want to move from A to B Controller set stroyboard id ie "SecondVc"
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "SecondVc")
self.navigationController?.pushViewController(vc, animated: true)
or just make connection using storyboard

Custom segue with Navigation Controller to another storyboard swift

I have navigationController embedded VC(Viewcontroller) in storyboard 1 which is connected to storyboard reference of storyboard 2.
Now, I have VC2 which is again NavController Embedded in storyboard 2.
I am performing the following code :
let storyboard = UIStoryboard(name: "Settings", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "setEdit") as? EditProfile
navigationController?.pushViewController(vc!, animated: true)
settings is storyboard 2, setEdit is ID from navigationController of the destination VC.
When I execute this code, It doesnt perform the presentation of new controller. Also, I have a custom segue class that transitions VCs from Right to Left.
when I use :
present(vc!, animated: true, completion: nil)
It just pushes the VC from bottom to top.
Now I am totally out of Ideas.
My query is:
How can I exactly implement custom segue from one storyboard to another, having navigation bar at the top.
When you use UINavigationController the transition is showed as you said from right to left (push), when you present a view controller modally the presentation style and the transition style are different. Now you cannot connect two navigation controllers, so I suggest to connect directly the controller in the settings storyboard without embedding it in another navigation controller. In settings storyboard you have to set your EditProfileVC as initial view controller and check its identifier and then you can push it from your first storyboard.

Programmatically use NavigationController inside ViewController

I have ViewController created using StoryBoards and I set it's class to be MyViewController.
MyViewController is class that inherits from UIViewController and have some UI elements. One of this elements is UIButton. I can programmatically add actions to this button as addTarget.
I want to to change view in NavigationController when button is clicked
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let newViewController = storyboard.instantiateViewController(withIdentifier: "newViewComtroller")
navigationController.pushViewController(newViewController, animated: true)
But nothing happens - why?
Check in your storyboard if your view controller has an embeded Navigation Controller. If not, you can click in your view controller, go to "Editor" on XCode's menu, "Embed in", and choose "Navigation Controller". After that, your view controller will be associated with a navigation controller, and you should be able to use the method "pushViewController" properly.

How to change the initial view controller of storyboard?

I have 2 view controller ,and I disabled the initial view controller of first view controller ,and enabled the second view controller,but when start the project,the initial view controller is still the first view controller ,what should I do? Thanks!
Tap the second view controller, and select "Is initial View Controller" in Attributes inspector.
Alternatively you can do this with code too.
In your AppDelegate class's didFinishLaunchingWithOptions method you can write
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let secondVC = storyBoard.instantiateViewControllerWithIdentifier("SecondViewController") as! SecondViewController
self.window?.rootViewController = secondVC
Edit Swift 3.0
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let secondVC = storyBoard.instantiateViewController(withIdentifier: "SecondViewController") as! SecondViewController
self.window?.rootViewController = secondVC
Assuming that your storyboard name is Main.Storyboard and your SecondViewController Storyboard ID and Restoration ID is also set in Identity Inspector and use Storyboard ID is checked.
If you are starter like me ( both iOS and OSX mechine ) and you wanted to change the entry point within same storyboard, then,
-> long press on the entry point arrow.
-> drag it to the view controller you wish to make the starting point, the arrow will now move to your new screen.

Swift ios not sure how to add navigation bar to VC in storyboard when using storyboard id

I am reseting my root VC in my app using:
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
let vc = storyboard.instantiateViewControllerWithIdentifier("testVc")
let navigationController = self.view.window?.rootViewController as! UINavigationController
navigationController.setViewControllers([vc], animated: true)
So since I dont have a segue I have a sotyboard id for that VC. The only problem now is that I dont know how to add a navigation bar in my storyboard to that VC.
The VC shows up as completly white/empty in my storyboard but once I run my app and it gets assigned as root it also get a navigation bar which is right, but I would want to add one using storyboard and not code.
If I simply drag a navigation bar in storyboard and start the app. It will result in the navigation bar being placed under the other navigation bar.
You do not add a navigation bar in the storyboard. We're going to use the navigation controller's navigation bar.
You add a navigation item in the storyboard. Now you can configure, in the storyboard, what should be in the navigation bar when you are in a navigation interface.

Resources