iphone RootViewController Login or Menu - iphone

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

Related

Is it okay to use a Modal segue to leave a view that won't ever show up again?

I am working on an app that, when you first launch it, has a login screen that connects to a server. If you enter a valid username and password, this login screen goes away and you are taken to the main screen for this app.
The main screen gives you options of what to do, and it is assumed that you will not go back to the login screen again probably. Maybe 1% of people might log out of the app and go back to the login screen I guess.
Since I am not using a Navigation Controller to go from the login view to the main view, I have to use a modal segue, but it doesn't feel right to do so, as far as my knowledge of the theory behind modal segues. Am I crazy? Should I maybe just somehow use a Navigation Controller anyway?
I just feel this is not proper style, to use a modal segue to basically cover up the login screen, when it really isn't needed anymore.
You should have a home screen (main view controller) that displays the login screen modally on app start. Once login is complete you can dismiss the login screen and your app is running as usual.
It's extremely bad practice to leave a view controller running when it's unlikely to be used again.

Trying to understand segues, memory management, and best practices

What I'm doing is creating a login screen as the first page. Once you login and it verifies you against the server it clears the login fields and it segues to a home screen. That screen has a back button that I've given the text logout. Clicking that takes you back to the login screen, and since the login button verifies you against the server before the segue it essentially looks like you're logging out.
However, I would like a logout button on each page. My thought for this was to add a button to the navigation bar of the other screens. As a test I added a logout button to a screen several levels in and added a segue back to the login screen. I updated a label on the page to see if it went back to the same page. When it segued back to the login screen the label was blank leading me to believe I didn't go back to the login screen, but rather it created a new login screen. How do I log out and have it essentially go back to the beginning?
Am I going about this the right way or is there a best practice in regards to this?
Every time to transition to a new view controller via a segue you are creating a new instance of the destination view controller. So yes, if you go back to the login screen using a segue you will be adding more view controllers to the navigation stack.
It sounds like you are using a UINavigationController. If so you can use the method popToRootViewControllerAnimated: to remove all view controllers from the navigation stack and return to the root (which is your login view controller). The other view controllers will be dealloc'ed when they are removed from the nav stack and you won't have the eventual memory problem you describe.
// do this when the user clicks your Logout button
[[self navigationController] popToRootViewControllerAnimated:NO];

Instagram iPhone application questions

I'm developing an application like Instagram for learning iOS programming.
My application is a client for an images hosting website where users can share picture from own iPhone.
I have few questions:
When you open Instagram and you're not logged in you don't see the tabbar with five buttons. You see a black bar with two button for login and signup. How can I hide the tabbar and show a bar like that (probably it's a standard bar, right) if the user is not logged in?
Relying on your opinion, what is the role of the application's model? (should I use a model or you hint me to use only view controllers?) The first thing that comes in my mind as "data model" it's the images array. This array will refresh when a user click on the "Refresh posts" button. There's also "Popular images", so I think it's another array separated from the global images array. Should it inserted in the model, right? I ask this because I would to organize in a good way my application for model/controllers/view pattern.
If you give me some hints I would be very grateful!
Present the modal view controller without animation, like siuying said. The modal view controller can hold its own instance of UITabBarController, so you can have a tab bar there that has a login tab and signup tab or similar. Behind, in the real, main view controller, have your normal five or however you're doing it. That way, once the user is signed in, you can just dismiss the modal view controller. Easy
I don't entirely understand your question here. Load the images on their own thread when the tab is clicked on for speed/resource use. I don't see how a model comes into this. Can you clarify this? Thanks.
You may modally present a view controller (without animation) on launch, when user is not logged in. You may then dismiss the modal view controller after login finished successfully.
Model here usually not only refers to the data (images array), but the logic and behavior of the app. For instance, download images from server should be implemented in model. You may want to check MVC Pattern.

Presenting login and registration view

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 !!

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.