How to get navigation based template functionality in Swift programming
I would like to replicate your idea into what I usually do in the following example.
This is how my storyboard looks like:
As you can see login/signup and Tab bar is not connected with any kind of Segue.
Here Sign in Navigation controller is setup of Initial Controller.
Assign This Navigation Controller an Storyboard ID(e.g.LoginNavigation):
Do the same with Tab Bar Controller, assign Storyboard ID(e.g. HomeTabBar)
Now, you just have to shuffle Root View Controller of the app between Login Nav and Tab Bar.
So if user successfully logs in, changes the application's root view to HomeTabBar using following code:
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let home: UITabBarController = storyboard.instantiateViewControllerWithIdentifier("HomeTabBar") as! UITabBarController
appDelegate.window?.rootViewController = home
And when user logs our, again change the root view to Login Nav:
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let entryPoint:UIViewController = mainStoryboard.instantiateViewControllerWithIdentifier("LoginNavigation")
appDelegate.window?.rootViewController = entryPoint
The appDelegate
is defined in my constants.swift
file :
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
Better way to identify if a viewController was reached by popping the navigationController or using the tab-bar
So to recap, there seems to be no way outside storing the fact that the push was performed as a state. From the answers provided below, this state can be set by implementing the UINavigationControllerDelegate
and using the navigationController:willShowViewController:animated:
method:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
self.disappearedDueToPush = !(viewController == self);
}
If implementing the delegate seems a bit heavy handed (it did to me) you might up the following in your viewDidDisappear method instead:
if (self != [self.navigationController.viewControllers lastObject]){
self.disappearedDueToPush = YES;
}
This made more sense to me as the reverse logic (and checking towards the fact) is performed in the viewWillAppear method.
Segue Presently from Appdelegate to UITabBarController in swift
You need to set your viewControllers
instead of pushViewController
rootViewController.viewControllers = [viewController]
Instead of
rootViewController.pushViewController(viewController, animated: true)
Tab bar controller inside a navigation controller, or sharing a navigation root view
The two previous answers got it right - I don't use UITabBarController
in Tweetie. It's pretty easy to write a custom XXTabBarController
(plain subclass of UIViewController
) that is happy to get pushed onto a nav controller stack, but still lives by the "view controller" philosophy. Each "tab" on the account-specific view (Tweets
/Replies
/Messages
) is its own view controller, and as far as they are concerned they're getting swapped around on screen by a plain-ol UITabBarController
.
Changing UITabBar during Navigation in iOS
Upon further research, decided that this was not feasible to do.
Related Topics
How to Get Commoncrypto/Commoncrypto File From
Firebase .Indexon Dynamic Keys
Swift - Image Data from Ciimage Qr Code/How to Render Cifilter Output
How to Fill Uitableview with a Data from Dictionary. Swift
Count Unseen Messages with Firebase in Swift
Set a Maximum Number of Children in Firebase
What Is Lldb_Expr in Swift Playground
How to Store Push Notification Alert Message in Userdefault
Storing and Retrieving Image in SQLite with Swift
Different Font Size for Different Devices in Xcode 6
How to Consecutively Present Two Alert Views Using Swiftui
How to Display Nested Array Data Inside Uitableview Properly with Multiple Level of Sections
Selector to Get Indexpath Uicollectionview Swift 3.0
How to Create Otp Verification Screen and Detect Delete Backward on Multiple Uitextfield Is Swift
Swift: Unrecognized Selector Sent to Instance