views:

36

answers:

1

HI, everyone,

I want to ask a question about the iPhone application. I am writing a program. The program will ask the user the enter some information and press enter, after that the program will process and get some information, then the program will display the tab page with 3 tabs.

However, I don't know how to switch the page after the user enter the information, I have write the following code.

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    [window addSubview: tabBarController.view]; // add the tab page to the view controller

    MyViewController *aViewController = [[MyViewController alloc] initWithNibName:nil bundle:[NSBundle mainBundle]];
    [self setMyViewController:aViewController];
    [aViewController release];

    UIView *controllersView = [myViewController view];
    [window addSubview:controllersView];  // add the first page to the windows in order to let the user enter info.
    [controllersView release];

    // Override point for customization after application launch
    [window makeKeyAndVisible];
}

If I add the tabBarController first, the controllersView will not appear, if I change the seuqence, it don't know how to make the controllersView disappear to let the tabBarController appears.

And the process is done in the MyViewController.m. Can I

1) remove the controllersView in the MyViewController.m after I complete all the process and

2) display the tabBarController.view ?

Thank you very much.

+1  A: 

Hi

You need to use a UINavigationController as the root view-controller for your window. You can then push the first UIViewController (MyViewController) on as the top view.

  • (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated

When its time for the tab view to appear push it onto the Navigation Controllers stack. To get back to your top view pop the ViewController off the stack

[self.navigationController popViewControllerAnimated:YES];

Warren Burton
@Warren Butron, thank you for your reply. As I am a green of the iPhone application, I don't really understand what you are talking about. Would you explain more about the ideas? and if I use the UINavigation Controller? Will it appear the UINavigationBar? (I don't want it). Thank you.
Questions
The UINavigationController provides a mechanism for swapping pages/views. If you add one to your MainMenu.xib it will provide a starting point. But do check out the sample code.Even if you are using a nav controller you can hide the navigation bar see setNavigationBarHidden:animated: or the navigationBarHidden property.
Warren Burton
@Warren Butron, thank you for your reply. But I still don't understand what you mean. Would you provide some documentation or example (e.g. apple website) to me for refer. Thank you.
Questions