Presenting login and registration view - iphone

I am working on an app whereby the user will have the login before using the services. How should I do about doing so, considering the user might register for an account through a UIButton on the login page, which will bring the user to registration view.
Can I use presentModalView to show the login view? If so, how do present I the registration view? Upon successful registration, the user will be auto logged in with the newly created account.

You should create a Modal View Controller (Login View Controller) and set that inside a UINavigationController. If you use a Registration UIButton there, you will be able to navigate to the RegistrationViewController and based on the events happening, you can choose to dismissModalViewController.
A detailed explanation on what you are looking for... is provided here - Show / Hide tab bar !!

Related

Login screen shown just once

i'm making app based on tab bar with two tabs. My problem is that i have to implement authentication view "loginView" on one of tabb's view, and when the credentials are saved i want show another data everytime tab is tapped. what's the best way to do it ?
Store a boolean in your user defaults, something like 'loginShown', then, in your appplicationDidFinishLaunching method, check if the 'loginShown' is set, and if not, present a modal view controller which is your login view.
You can use a modalViewController for Login so you can have some other view beneath it. For saving credentials for Login so that the user does not have to log back in, you can store it in the KeyChain.
Use this reference: http://log.scifihifi.com/post/55837387/simple-iphone-keychain-code

ViewController data sharing

So I have two view controller that I load on the app delegate when the app loads. One is for a login page where I have a username and password and the other one is a UITabBarViewController. After the user login, I just remove the login view and therefore showing the UITabBarViewController. The problem is that in my UITabBarViewController, I need the username and password from the ViewController. How can I solve this?
ADDITIONAL INFO:
Here's basically what I want to do:
Application starts with an Logon on page: User ID, Password and Logon button
On clicking the logon button, after validating the credentials, we've to take the user to the next screen with
an Navigation Bar on the top (essentially an UINavigationController)
Table view
Tab Bar in the bottom
Now after logging in, I want all the ViewControllers in the UITabBarViewController to be able to get the username and password that the user enters in the first login screen.
I think the best design is to have the your controller for the tab bar present a modal view controller for login. The controller tab bar would then be the delegate of the LoginViewController and the LoginViewController would notify its delegate when the login is complete. When the login is completed successfully then the controller for the tab bar can dismiss the LoginViewController.
Now I wrote this code after you updated the answer. You can figure out how to add the UINavigation bar and table views your self. The question is about passing data between view controller not me answering how to through a bunch of views together. I highly recommend to iTunes U course from Stanford on iOS programming if you want to learn more about putting many views and controllers together for a complete app.
I provide a full, complete and working example demonstrating proper use of delegates to share data between the LoginViewController and a UIViewController (In your case the UIViewController would be replaced by your tab bar controller). I also demonstrate how to use NSUserDefaults to save this data which is accessible from elsewhere is the app.
All the code for the example can be found here.
1 Use root controller to share the data.
You can put the data in your root controller and the root controller creates two view.
The root controller can transfer the data to its child views.
2 Or use class constructor.
When you create the views, you can give them parameters with data.
That is not a big Problem.
You can create two NSString variables in the appDelegate class and set the property to them. So that you can access those variable in the entire project.
You will set the values in the login page and you will access those in the tabBarController.
Thats it.
Reagards,
Satya

Application Layout

my application's layout is:
Tab controller
--> UIViewController1
--> UIViewController2
--> UIViewController3
I need a Login Screen before that, so I show a popup with "presentModalViewController" in the "didFinishLaunching" in app delegate.
But I want a login screen with a nav controller, this:
Login screen:
--> Select REGISTER or LOGIN
-> if REGISTER --> show view for register
-> if LOGIN --> show view for login
So I suppose I need a NavigationController, it's right?
I've readed many questions and one suggest me to create a layout like this:
Navigation Controller
--> Login Screen (with REGISTER or LOGIN) ---> register or login view ---> close view and show tabbar
Which between these ways is more correct?
I would use the navigation controller when they go into the registration section. This would allow the user to step back out after they go in and also allows for some flexibility if your registration process ever needs to be made into multiple steps.
Another suggestion is that you should put the actual log-in form on the first view. This way users that have already registered with you will not have to perform 2 steps just to log-in.
Login Screen
Login Form
Register Button -> Register Views

iphone RootViewController Login or Menu

This is kind of on the back of a previous question. Im currently throwing together a simple social networking iphone. For my question you can think of the application to be quite similar to the facebook iphone app.
It is based off the navigation template and the menu view is the top level view controller for my navigation controller. The user needs to log in to use the application.
Im just wondering whether the navigation controller should be the starting view and if the user has not logged in (when the user logs in I will store the login information so that they do not have to login next time the open the app) than it will throw the login page up modally. Or if the login page should be the startup view and on login the login control will create and go to the navigation control.
Thanks in advance
If the user needs to log in before using the application, then showing the login screen modally is probably the best bet for the first view that gets displayed.
Apple does this with their iTunes Connect app that is available when you go to view your sales data. They show a black screen while the app is loading, modally display the login screen, then dismiss the view to show the guts of the app.
Plus in your case it would be nice to have the navigation controller ready in the background by the time the user login screen gets dismissed (i.e. you could delay it with an activity indicator while readying the view). It would give the impression of a more responsive app

How do I get a login screen on an iPhone app (using tabBarController)?

I am developing a web app (using rails) that I will be launching within a week. I've "jumped the gun" and started working on the iPhone app for the site (I'm new to iPhone development). Using the peepcode iPhone screencasts and the expense/budget demo app from clarkware I've been able to get things going (using ObjectiveResource for iPhone-to-Rails communication). So I'm able to get a tabBarController loading a table with test data populated from my staging server online. Great.
My problem lies in that I need login functionality. The budgets demo app has this nailed but it uses a navigationController. I would like to use a tabBarController (which I'm using currently) to handle the basic functionality of the app.
Here's how I see the app login functionality working when completed:
When a user first runs the iPhone app, the iPhone app will present a login screen (username and password). If a correct username and password is entered the session/user info is saved (preferably to the general/settings app section of the iPhone). The user won't be presented with the login screen again unless the session expires, the user edits the username/password in the general/settings section of the iPhone, or the user deletes the application and reinstalls.
The closest thing to what I have in mind for this process is the Gowalla app.
So I suppose my question is: What is the best way to get a login screen to appear when using a tabBarController? Once I can do this and get authentication taken care of the rest should fall into place.
Please let me know if there's anything I need to clarify - THANK YOU!
-Tony
Do you want to have the tab bar to display at the bottom? Then just put the Login View Controller as the selected tab by setting the selectedViewController or selectedIndex properties of UITabBarController.
Do you want to have the tab bar display at the bottom but not be actionable until they've logged in? Then set a UITabBarDelegate and override the tabBarController:shouldSelectViewController: method to disallow until login has happened.
Do you not want the tab bar to display until login has been entered (personally I would think this is most desireable)? Then either don't show the TabBarController until you're ready, show the Login View Controller instead... or, alternatively, show the Login Controller as a Modal View Controller over the TabBarController and don't allow it to be dismissed until login was successful.
I am new to iPhone programming, but have done C++ coding moons ago. So far I have created everything programmatically rather than use the nib approach.
For what you what to achieve, I would create a main view controller from the app delegate. Then from this main view controller I would create the login view (UIView) that initially displays and seeks the users login credentials. Once validated, your main view contoller can the create and display (or just display if you created it initially) a tab bar controller with the appropriate view controllers for each tab.
So appDelegate -> Main View Controller -> Logon View
-> Tab View Controller + View Controllers
Hope this helps?!
Matthew.