Blog Index
« Cloud-based game -- The next big thing | Main | For Liberty: How the Ron Paul Revolution Watered the Withered Tree of Liberty »
Wednesday
Jun302010

Modal Form Sheet + Navigation Controller

This quick tutorial shows you how to create a modal form sheet with a navigation controller to display master-detail view for your iPad application.  Basic knowledge of iPhone programming is assumed. Download the sample code here.

Step 1) Create a navigation controller and initialize it with the first view controller (TestModalViewController in this case) to show.
Step 2) Present the navigation controller as modal.


        // Step 1
        TestModalViewController *viewController = [[[TestModalViewController alloc] initWithNibName:@"TestModalViewController" bundle:nil] autorelease];
	modalViewNavController = [[UINavigationController alloc] initWithRootViewController:viewController];

        // Step 2
	modalViewNavController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
	modalViewNavController.modalPresentationStyle = UIModalPresentationFormSheet;
	
	[self presentModalViewController:modalViewNavController animated:YES];





3) In TestModalViewController, create a done button for the modal form sheet.

- (void)viewDidLoad {
	[super viewDidLoad];
	
	self.title = @"Modal Form Sheet Test";
	self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismiss)];
}

- (IBAction)dismiss
{
	[self.parentViewController dismissModalViewControllerAnimated:YES];
}


4) Write the code to push the detail view (TestModalDetailViewController) into the navigation stack (in this case when user taps the Show Details button).

- (IBAction)showDetails
{
	TestModalDetailViewController *viewController = [[[TestModalDetailViewController alloc] init] autorelease];
	[self.navigationController pushViewController:viewController animated:YES];
}



PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>