Search code examples
iphoneviewnavigation

iPhone - What is the correct way to setup app navigation for different types of views/windows?


As a newcomer to objective-c and IOS one of the hardest things I've found to get my head around is how to load new views and move between what I want to display to the user at various stages of the application.

I have started by creating an app with a Tab Bar controller at the bottom and a navigation bar at the top, I have grasped this and how to load different views for each tab bar item.

However I want to expand the app so the following happens,

The user loads the app, first off a plain login screen appears, if the user enters correct details the app moves to my current setup of the tab bar and navigation bar if they enter incorrect details they go to a plain error page.

So I'm not sure what I need to change in my app to achieve this, do I need to create a new window and put a view in it for the login screen and then how do I load my current setup?

Do I change my Main Interface to a new window? Or do I have to change my current MainWindow.xib to load the login view and then re create my current setup in a different xib file?


Solution

  • Usually We can use one UIWindow only in iPhone SDK.So We have to handle all things through one UIWindow.You can use the following code in your AppDelegate.m file.When user clicks login button, you can remove login page and show Tab bar controller

    - (void)applicationDidFinishLaunching:(UIApplication *)application {    
    
    // Override point for customization after app launch    
         [window addSubview:viewController.view];// you log in page
         [window addSubview:tabController.view];//Your Tab bar controller
    [window makeKeyAndVisible];
    

    }

    -(IBAction)Login_buttonClicking
    {
    [viewController.view removeFromSuperview];
    }