About tab bar using storyboard - ios

I want to create an app using storyboard that has login window and tab bar controller.
So the flow will be upon tapping the login button, the app will be redirected to tab bar controller with its views.
I have done this:
But referring to Apple Documentation: UITabBarController
Because the UITabBarController class inherits from the
UIViewController class, tab bar controllers have their own view that
is accessible through the view property. When deploying a tab bar
interface, you must install this view as the root of your window.
Unlike other view controllers, a tab bar interface should never be
installed as a child of another view controller.
So that means I am not allowed to do so?
In addition:
The 3 views that are referred by my tab bar, then each of them has their own child view again, but the tab bar in the child view is gone. What could be happen? Am I missing something?

What I have done in all my apps that are structured similarly is to have the first view controller check for valid authentication and if that fails, present a login VC. That login VC has a delegate defined that will pass back the user credential after a successful login and then dismisses the modal login VC does whatever.
Here is a sample layout:
The delegate protocol looks like this:
#protocol LoginViewControllerDelegate
-(void)finishedLoadingUserInfo:(UserInfo *)curUser;
#end
Where UserInfo is the model I use for the user information (in my case, NetworkID, FullName, etc).
When the user has successfully authenticated, I fire off that delegate method which is handled in the class that presented it. If you need more detail, I can help - but the process is simple.

You can launch your login screen first from the appDelegate and then setup and launch the tabBarViewController after the login is successful.
An alternative design is to do the following steps:
1. set up your tabBarViewController,
2. disable the tabs,
3. launch your login view controller modally,
4. enable tabViewController tabs
Either of these two approaches should work.

Related

How do I make the login screen with the main tabview controller that makes it open the first time the app is opened

Link to image here
This is the view of the screens
I want
I can't link it to the main tab bar controller
Give the nav controller that parents the login screen a storyboard identifier. Next, create a custom UITabBarController subclass and assign it to the Tab Bar Controller. In its viewDidAppear method, check to see if you need to log in. If so, instantiate the login nav controller via its storyboard ID and present it modally.
Set your login screen as initial view controller. You can set view controller as initial view from attribute inspector. When user login's successfully, present your main tab view controller.

UINavigationController limited utilization in app design

I am using the NavigationController (Embedded via Editor drop down menu in xCode) to control navigation on sign-up and sign-in views, all from landing view when app first launched.
After user sign-up or login, I would like to initiate a view controller with no relation to the NavigationController. Nonetheless, from Sign-up and Login views, I have a segue that links (upon successful authorization) to the main view of logged in users. How can I remove the navigation controller from a certain part of the application because it is no longer needed? Otherwise, each time I add a new view controller, it shows the navigation bar in it which is not ideal for design.
Thanks and image attached shows what I need illustrated.
As far as I am concerned you can remove only view controller from navigation stack. If you do not want navigation bar to be visible, then just hide it in viewWillAppear of view controller that you want to be without navigationBar.
[self.navigationController setNavigationBarHidden:<#(BOOL)#> animated:<#(BOOL)#>]

Starting app with login page when tab bar controller is present

I have conditional code in my app delegate's didFinishLaunchingWithOptions: method that uses HTTP requests/responses to determine if the user is logged in already. I'm running into serious hierarchy problems, and my question is this: should I be starting my app with the login page (and make the app delegate conditionally load my tab bar when the user is logged in already), or start with my tab bar (and make the app delegate conditionally load my login page)?
This is my storyboard currently
I would make the tab bar controller the root view controller of the window, and present the login controller from the viewDidAppear method (without animation) of the controller in the first tab. Also, you should not go backwards in a storyboard with a segue, unless you use an unwind segue. Segues (other than unwinds) alway instantiate new controllers, so you're not actually going back to a previous controller, you're instantiating a new one. This will cause more and more controllers to be added to your hierarchy as the user navigates back and forth.

How to segue to a view managed by Navigation Controller?

I am working working on an app (iOS 5+) that contains a stacks of views that are managed by a navigation controller:
MyNavController -> MyRootViewController -> MyTableViewController -> MyDetailViewController
I also have view controllers that are not managed by the navigation controller for handling the login (LoginViewController) and registration (RegViewController) of the app.
When the app is launched, it will check if an account has been created. If so, it will seque to the LoginViewController for user login, and then it will segue to MyRootViewController. However, if no login is detected, the user will be presented with the RegViewController scene to create an account. Then, I would like to take the user directly to the MyTableViewController scene, bypassing the RootViewController scene. Is this possible (via Storyboard or programatically)? I have attempted to define a modal segue from RegViewController to MyTableViewController, which seems to partially work - it is able to go to the scene but with the nav bar missing on top of screen. But when I select a table item it fails to go to MyDetailViewController. It crashes with error "Push segues can only be used when the source controller is managed by an instance of UINavigationController."
Any advice?
Thanks in advance.
Select your MyDetailViewController. On the top select editor->embed in ->navigation controller.

iphone app with uinavigationcontroller and uitabbarcontroller

I'm new to iphone programming and i'm trying to build an application that has a uinavigationcontroller and the rootviewcontroller is a uiviewcontroller that is basicly a login screen from the login screen the user moves to uitabbarcontroller that has 5 tabs and each tab is a uinavigationcontroller and each navigationcontroller has two button in the navbar one button brings a messages view and the other notifications view each view is a uiviewcontroller.
Now the user can press the message button on every tab and the message view will appear and i want to make sure that if he presses the button on the first tab and then goes to another tab then the message view will disappear and deallocated from memory and when he presses the message button on the new tab then another message view will appear.
I tried the create a single message view in the app delegate and every time that the user presses the message button to call a method from app delegate then in the method i check which tab is pressed and push the view to the navigation controller that belongs to that tab but that doesn't work properly.
You can embed your login views inside the AppDelegate and show them as needed. From there you would load your rootController, which should be your tabBar. Then you can load up your navigation controller inside each tab. One for each tab. Your message view can be called from any of the tabs. Just need to make sure you layer your controllers the right way.
AppDel --> TabBar --> NavController --> Individual Views
Do you realize that you can replace the root view controller in a window? Your app delegate's -applicationDidFinishLaunching:withOptions: method probably does something like:
window.rootViewController = loginViewController;
When you set the window's rootViewController property, the window will add that view controller's view as a subview of itself.
There's nothing particularly special about -applicationDidFinishLaunching:withOptions: -- it just happens to be the delegate method that's called when the app has finished loading and is ready to get down to business. You can set the window's rootViewController property just as well from other methods, so when your login view controller determines that the user has successfully logged in, it can do something like one of the following:
instantiate the tab bar controller and set the window's rootViewController property itself
send a message to its delegate (which would probably be the same object as the app delegate) to inform it that login was successful; the delegate could then install the tab bar controller
broadcast a notification to tell anyone who cares that login was successful, and let someone else install the tab bar controller

Resources