I'm reading a book called Beginning iPhone 3 Developement - Exploring the iPhone SDK, by Dave Mark and Jeff LaMarche. I've read about navigation controllers and multiview applications, and now I want to create my own little app, a very simple Twitter app. I want a login view, and if the login is successful I want the user to be presented a view with a tab bar, where each tab is Update, Timeline and such. Right now I'm just going for the update view.
So I thought about a navigation-based app. The first view, the login view, is on the bottom of the stack. When the user logs in, the view with the tab bar is pushed on to the stack. Then the user does whatever (s)he wants there, in the tabs. (S)he should then be able to press some kind of logout button, which pops the tab bar view off the stack, and takes the user back to the login view.
Now to my question (sorry for my long explanation): is this the way to go? If so, how do I do it? Do I create a view controller called LoginViewController, which is subclassing UINavigationController, or what?
From a UI perspective, a more fluid design might use a modal view controller.
A modal view controller pops up from the bottom of the screen and displays its own view. When this view is dismissed, it shuffles down and disappears.
In my opinion, a modal controller is a good place for a transient authentication screen — you just bring it in view, the user enters his or her info, and the view is dismissed.
On returning to the parent view controller, it checks the authentication credentials and modifies its view if authenticated (or not).
Another advantage of the modal view controller is that it is on its own navigation stack. So you don't need to push a controller, pop up and then push a different view controller. It makes for cleaner code and a cleaner interface (again, in my opinion).
Related
On my application, I have four view controllers (VC):
HOME
MESSAGES
PROFIL
SETTINGS
On each VC, an opaque bar bottom with four bar button items for each VC (home, messages, profil, settings).
When I tap on one bar button item, I manage the navigation with a segue (show) and it loads the selected VC.
I would like to find a way to not load again a VC already loaded one time.
For example:
The app is launched
HOME VC is loaded and appears
User taps on PROFIL
PROFIL VC is loaded and appears
User taps on HOME
HOME VC appears without calling viewDidLoad method, because it has already been loaded four steps ago
I tried with all types of segues (show, present modally, etc.) and with presentViewController method, but each time the viewDidLoad method is called.
Is there an easy way to do this or do I have to manage this with a boolean to indicate that the view was already loaded?
I would like a menu like WhatsApp application has for example.
WhatsApp uses a Tab Bar at the bottom. Are you using Toolbar? ViewDidLoad only executes once per view unless you unload the view from memory.
The easiest way to adapt your app is to just add a Tab Bar Controller in your app and then delete the 2 automatically added view controllers and set a relationship (just like a segue; it's below segue types) between each view controller and the tab bar controller. To change the icons, modify them in the Tab Bar Controller View. Then segues will work automagically just like in WhatsApp. :)
I want to build an app using swift with the following structure:
Login/Signup screen
Home screen with slide out menu on the left
Different Pages in the menu -> same level like home screen
![Picture of the structure][1]
// Sorry not enough reputation for posting images
Here is an example, but I don't understand it.
GitHub-Link
![Picture of the controller structure][2]
Why is the Login-Screen the rootViewController of the Navigation Controller?
Why is there no "back" button on the other controllers of the menu (Friends, Profile)?
I could remove the segue from Login to Profil and the app still works fine...it's a normal push segue. I don't understand what that sequel does.
I thought every controller which is not the rootviewcontroller of the navigation controller gets pushed on the stack and a "back" button...
Should i split the Login and the Signup screen into two different controllers?
My suggestion:
1. Login screen/Signupscreen
=> Modal segue to navigation controller
2. Navigation Controller => RootViewController: Page 1
But how should I implement the Page 2, Page 3,... at the same hierarchical level as Page 1
How would you structure the controllers?
[1]: http:// i.imgur.com/qHMy6zs.png
[2]: http:// i.imgur.com/wdOGCGa.png
Looking forward to your answers!
Jan
Why is the Login-Screen the rootViewController of the Navigation Controller?
It does not have to be, it's a design decision, personally I would not do it that way.
Why is there now "back" button on the other controllers of the menu (Friends, Profile)?
Pushing a view controller onto a UINavigationController will do this automatically unless you specify that the back button should not be present in the view controller that gets pushed. UIViewControllers have a property called UINavigationItem where you can set the back button to hidden. See here.
I thought every controller which is not the rootviewcontroller of the navigation controller gets pushed on the stack and a "back" button...
Yes that's right, you sort of just answered one of your previous questions.
Should i split the Login and the Signup screen into two different controllers?
Yes that would generally be a good idea. Have a separate view and view controller for each of them. It does depend on your ui design also.
How would you structure the controllers?
It appears you have multiple menus and different sections to your app. In that case using a UITabBarController combined with multiple UINavigationControllers (one navigation controller per tab) may be one way to go about it, I've used this technique before and it works well.
If I a mistaken based on your images and you actually just have one main menu then stick to just one UINavigationController and just push and pop view controllers, have one view controller / view per view/page of your app.
Best thing is to read up about UINavigationController and UITabBarController and decide what suits how you want to layout your views / your design.
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 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.
I am working on an application that requires user authentication to access a profile. The profile section is located solely under one tab (and all others tabs do not require authentication). I currently present a authentication view controller modally (and then dismiss on success) when the user selects the profile tab. However, this approach prevents the user from deciding not to register / login (that is, all tabs are hidden once the authentication screen is presented modally). I don't want the user to be able to dismiss the modal view controller, but rather have it modal only for the profile tab. Is this possible? Can I have tabs visible while having a modal view controller? What is the best approach here. Thanks.
The entire point of a modal dialog box or view controller is to force the user to look at or do whatever the modal view is requesting, and prevent them from doing something else with that application. It seems to me that the best approach, if you still want to use a modal view controller, would simply be to have a "Cancel" button or something on the view controller. Since the profile tab can only be accessed after authentication in the first place, just have dismissing the view controller make the last-viewed tab the active tab.
Xcode 10:
In the Attributes Inspector, inside View Controller section, you've the Presentation option.
a) If you choose Over Current Context, the modal view just will appear over the view, but the Tab Bar will appear at the top of the view.
b) Otherwise, if you choose Over Full Screen, the modal view will appears over all the UI, including tab bars.