开发者

Utility App with Navigation Controller and Table View on FlipSide

开发者 https://www.devze.com 2023-02-01 05:15 出处:网络
I am relatively new to the whole MVC way of looking at things. I have an application that is based on the \"Utility\" Application template. Everything in the MainView and FlipsideView is working gre

I am relatively new to the whole MVC way of looking at things.

I have an application that is based on the "Utility" Application template. Everything in the MainView and FlipsideView is working great but now I need to add a TableView and Navigation Controller to the flipside. Without the navigation bar being on the MainView.

So only once the user has tapped the info light button will the nav bar display on the flipside with a table view. I have been able to impliment the Table View on the side and populate it with data from an array. I am now struggling to link in a navigation controller so that the tableview can become interactive. When I place the nav bar code into the app delegate it appears on the MainView and not the flipside view.

Where do I place the navi开发者_开发百科gation bar code so that it will display on the flipsideview. I cannt seem to get the code in the right place. Also I am not sure I have the right code, do I put the UINavigationController code in the FlipSideViewController.m ?

I am not grasping the concept of the naivgation controller fully I think . . .

Here is the code to bring up the FlipView

- (IBAction)showInfo 
{    
 TableViewController *controller = [[TableViewController alloc] initWithNibName:@"TableViewController" bundle:nil];
 controller.delegate = self;
 controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
 [self presentModalViewController:controller animated:YES];

 [controller release];

}

Now I need to get the TableViewController to have a navigation controller and a table view

Thanks in advance.


After you create your table view controller, create a navigation controller that contains this table view controller as the root. Then, present this navigation controller modally, instead of your table view controller.

I prefer to do this programmatically, so here's the code I use:

- (IBAction)showInfo 
{
    TableViewController *controller = [[TableViewController alloc] initWithNibName:@"TableViewController" bundle:nil];
    controller.delegate = self;

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
    [controller release];

    navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:navController animated:YES];
    [navController release];
}

In your table view controller, set up its navigation item to contain a button that, when tapped, causes your main view controller to dismiss the modal navigation controller (thus flipping back to itself).

0

精彩评论

暂无评论...
验证码 换一张
取 消