Search code examples
iphoneiosuinavigationcontrolleruitabbarcontrolleruitoolbar

iPhone application layout


I'm developing (for learning iOS programming) an application for images-sharing.

The wanted layout is this:

  • It's a tabbar application with three tabs.
  • When you open the application and you're not logged the tabbar is hidden and you see instead a toolbar with two buttons "SIGNUP" and "LOGIN".
  • The controller that you see when you open the app it's the same for logged and anonymous users. The anonymous users can see only this because the tabbar (as written above) is hidden and you see instead a toolbar for signing up and log in.
  • When you tap on login or signup button you see (with pushViewController of navigationController) a new pushed view for do the selected action.

For example you're an anonymous user and you open the app. You see the first controller with all images and a UIToolbar at the bottom with the two buttons. For example you tap on an image and you see a new view with the image details (the view is pushed with navigationcontroller). But also in the new view you can see the UIToolbar for sign up and login. So the UIToolbar it's always visible for the anonymous user.

My problem is always display the UIToolbar for anonymous users and push with a navigationcontroller the login or signup views.

I'm a newbie developer. Have you tips for do that? Thanks.


Solution

  • If I understand your problem correctly, you want to constantly display a UIToolbar for an anonymous user so that they can log in from any of your views? If this is the case, all you would have to do is include your login toolbar in every one of your views you want the user to be able to log in from.

    Another option, if I remember correctly, a navigation controller is technically both a top bar and a bottom bar. You could enable and utilize this bottom bar instead of adding your login toolbar to each of your views. To disable it for a know user, you would simply just hide it.

    Edit in response to comments: You should initialize the toolbar in your UINavigationController subclass, it would look something like this:

    customNavController.h:

    @property(nonatomic,retain) UIToolbar *toolbar
    

    customNavController.m

    if (toolbar == nil) {
            toolbar = [[UIToolbar alloc] init];
            navigationController.toolbar = toolbar;
    }
    

    That's the basic idea, though your initialize function for the toolbar will be different in that it will have the necessary UI for the login process. If you want some more information on the Navigation Controller I would highly recommend reading the class reference on it, it is actually very handy.

    http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html