I'm trying to develop a tab bar controller application with four UIViewControllers. I have already programed my app. Now I need to add Login in my App. I have added a separate UIViewcontroller for login (Which is not part of TabbarController). Login is working fine. How can I load UITabbarcontroller after login is success.
A solution to this is to create a UINavigationController to house the login view and when a login is complete you push the UITabViewController onto the Navigation Controller. It works well and you can just hide the navigation bar so the user doesn't just jump back to login(unless you want this).
You could also just swap out the rootviewcontroller of the window but I like the navigation controller solution better and you can easily popToRootViewController to go back to login when you want.
Related
I am doing an app in which on startup of App,a tabbarController with Search and Login views will be presented.When I click on Search tabbaritem SearchView wil appear.When Login tabbaritem is clicked Login view will appear ..When the Login is successful a tabbarcontroller with Four tabbaritems(Search,MyProfile,MyActivities,Logout)will appear.Now when I click on logout I have to logout of the account and I need to show again the startup view.
Any help would be appreciated..
its related with your application architecture. i would like to divide your question :
I m pretty much new to objective-C and I m doing an app in which on startup of App,a tabbarController with Search and Login views will be presented.
Reply: Initially you need to have a navigation controller in the AppDelegate which will work like a parent navigation controller and you need to add your tabbar controller as a rootviewcontroller to it, it will help to get out of the second tabbar controller when you want to logout.
When the Login is successful a tabbarcontroller with Four tabbaritems(Search,MyProfile,MyActivities,Logout)will appear
Reply: Now when you get logged in then you will push a new tabbar controller with 4 tabs, it will get pushed on the parent navigation contrller (that we created in app deleate) .
Now when I click on logout I have to logout of the account and I need to show again the startup view
Reply: Now when you want to logout and after doing all the logout related stuff(like closing the session etc) if you want to pop the view controller like [self.navigationController popViewController] it will not going to help you. as the self.navigation controller is the navigation controller of the new tabbar (of 4 tabs, that you pushed after login ). So you need to access the parent navigation controller here, which we created in app delegate into the Logout view controller, like : [appDelegate.navController poptoRootViewController] .
So the important point here is you need to have access and control over the parent navigation controller.
Hope this helps.
I've tried many different ways but can't get it to work. How can I make a simple login/logout view/app? I need the initial page to be a regular UITableView, once login button is pressed it should (push/addsubview ?) to a new UITabBarView (with 2 UITableViews in that), on the second tab exists a logout button, which should send you back to initial login page, also on the login page the nav controller and tabbar should never show up, (but I think I can figure that out). I tried pushing and popping viewcontrollers put that's getting messy. Xcode 4.1
Examples or help will keep me from pulling the little hair I have left out!
Thank You!
I 've wrote some thing, may be it took complex to understand by you but i've tried to explain, main theme is that to make a navigation controller and set it to app delegate window's root view controller then push login view controller to it, and then pushing tabbar controller, read below some explanation.
this is mostly done by making a navigation controller and setting it the app delegate window's root view controller, then make a view controller that is your login view and setting it the root view controller to app delegate's navigation controller, then make a tabbar controller (a view controller) which contains tabbar and navigation controllers on each tabbaritem, and furhter each navigation controller has a reference to tabbar controller(the view controller pushed at login time). So, whenever logins is pressed, it pushes the tabbarcontroller and performs tasks. and when you want to logout, just pop to root view controller of the referenc's navigation controller which in fact is the login view controller.
You can hide tabbar, then show it after login success.
https://github.com/idevsoftware/Cocoa-Touch-Additions/tree/master/UITabBarController_setHidden
I've created a small iphone app that contains a tab bar controller that has been created on the MainWindow.xib. The App Delegate contains the root controller outlet. I'm wondering how I can work in a login screen that will direct the user to my view controller containing the tab bars.
Current Solution:
On didFinishLaunchingWithOptions add subview "RootController" which loads my MainWindow.xib view with tab bars. Then call "presentModalViewController" to present the LoginViewController as a modal. On the login view controller, the login button click calls the AppDelegate to dismiss the modal.
Does anyone know of a better solution? Possibly a solution that doesn't load the page with tabs until after the user has logged into the app.
Thanks!
Make a separate View Controller (lets say A)
in didFinishLaunchingWithOptions check if user is logged in .. if not show A..
implement delegation and pass back login result to the app delegate...and then load the tab bar View
I want make a typical tabbar based application.
And I want to insert login view on startup before main tabbar is shown.
I tried to insert TabbarController in main view, but cannot find appropriate code. All sample code I found is insert TabbarController on startup. (in Delegate file)
My fellow suggest create toolbar on startup but hide it at login view, but I am not sure if this is a general method or not.
In this case, what is a 'recommanded' handling method of TabbarController ?
A simple solution would be to
1-Add the tab bar to UIWindow in the appDelegate as is suggested by apple.
2-then add a UINavigationController in tabbar using tabbarController.viewControllers=[NSArray arrayWithObject:yourNavController];
3- Now after alloc init on your login controller write this code before pushing it to the navigation controller of the tabbar
yourLoginController.hidesBottomBarWhenPushed=true;
4- push yourloginViewController to the navigation controller of the tabbar.
5- After authentication before pushing your MainviewController instance on the navigation set it like this
MainviewController .hidesBottomBarWhenPushed=false;
I hope these five simple steps will do the magic for you cheers :)
Please let me know if it helps you.Thanks
The approach I use for login screens which works great is:
prepare and show the regular main screen (tab bar controller with whatever initial VC you want to use)
immediately present the login screen modally (without animation) from the tab bar controller (which will obscure the tab bar controller, which is what you want)
make the login screen the startup image
I have created an app and a login and would like to join them together with no luck. The app has a tabbarcontroller with navigationcontrollers via tableviewcells to drill down to other views of the app.
As I am having no luck in joining the two. I have tried to build on from the login that I have done. I can push to a new view but it does not show a tabbarcontroller etc on the next view. I have seen various forums with people having this problem as well.
So, my question: How can I make a new page (login) open to a TabBarController instead of a view (in the middle of my app, not at the launch)?
Does anyone out there know how to solve this issue?
Use navigation controller in tab bar controller. lets say the navigation controller is its first view controller. Now when the root view controller of the navigation is being displayed, you can see the tab bar. Now if you keep pushing new view controllers in this navigation controller, the tab bar wont hide itself.
However if you present some view controller modally, it would hide itself.
As far as login is concerned, i will check if user has logged in or not. if no, then i would set the root view controller of navigation controller as loginviewconroller else some home page.
I would check the if the user is logged in in the first viewController that get loaded.
From there I would present the loginViewController via the presentModalViewController method.
The use will not see the tabbar if you set the withAnimation:NO.
Now just dismiss the login viewcontroller when the use is logged in.
One could also send a notification that the is logged in, so that viewcontrollers can update them self for the no logged in user.