I am learning ios/ xcode and at a roadblock.
I have a tabbarcontroller+navigation based design. I need to present a login screen if user is not logged in. Here is the basic heirarchy. The login page needs a navigationBar (as the tutorial I followed puts a "Go" button on the bar.
LoginController: (LTController.h,.m)
Main View:TabBarController>
NavigationController>View1>View1a
NavigationController>View2
I read lot of posts here on modal view, delegate method, etc. Most of them are code snippets which unfortunately are a bit over the head for my beginner level.
Would appreciate a simple explanation as to how to achieve this. Espacially a note on which files needs changes would be great.
thanks
it looks like you are off to a good start. Since you have a tabbar design, you have to make a choice on how to present the login page and when you will do that.
you have to either present it before the tabbar is shown, or put logic in your first view controller to initiate the login process. There are other ways as well, but they get more complicated and I wanted to give you basic choices right now.
Here is the general concept I'd recommend.
a) create a persistent storage variable somewhere to determine if a user is logged in or not.
b) add a check for this flag in the View will load method of the first view controller attached to your tabbar.
c) present a modal login page directly from the view controller. if they login, great dismiss it, if not, they are stuck on the modal page.
so, here is basically how to do that:
for purposes of explaining, I'll going to call your first view controller - first tab on your tabbar controller - fviewController - ok?
in fviewController.m
a couple more points it looks like you are using storyboards and segues. In that case, you would do the following:
To flip the status:
To dismiss the modal view. Technically you should use a delegate callback to do this, but if you are trying to keep things simple, this should be ok
So your logic would be like this - did they login? Yes, then set YES status for logged in and then dismiss. If they dod not login, do nothing. They are stuck.
Finally, if you need to setup your login controller, you would use the method: prepareForSegue ... to initialize variables before the segue occurs. You probably have read about it if you are doing some tutorials.
Well ... hope that helps. It is a very basic approach. If you get that working, you can continue to add more security and capabilities to it as you go.
best of luck.
Here is scenario . Its so simple . I just hope that it will be useful.
For the UITableBarController give a name for identity to storyboard id
Then in your ViewController class file You have the authentication credentials right >.? Do some stuff over there for authentication . then follow this code . It works fine