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];
}
tagged
modalformsheet,
navigation controller in
Tutorials,
iPhone
modalformsheet,
navigation controller in
Tutorials,
iPhone 

