cocoaTouch/iPad/SplitViewRootController.m
changeset 3113 2829ea0dd47c
child 3250 d5cd1a617123
equal deleted inserted replaced
3112:f1bbe35ddb83 3113:2829ea0dd47c
       
     1     //
       
     2 //  SplitViewRootController.m
       
     3 //  HedgewarsMobile
       
     4 //
       
     5 //  Created by Vittorio on 27/03/10.
       
     6 //  Copyright 2010 __MyCompanyName__. All rights reserved.
       
     7 //
       
     8 
       
     9 #import "SplitViewRootController.h"
       
    10 #import "MasterViewController.h"
       
    11 #import "DetailViewController.h"
       
    12 
       
    13 @implementation SplitViewRootController
       
    14 @synthesize splitViewController, masterViewController, detailViewController;
       
    15 
       
    16 
       
    17 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
       
    18     return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
       
    19 }
       
    20 
       
    21 -(void) didReceiveMemoryWarning {
       
    22     // Releases the view if it doesn't have a superview.
       
    23     [super didReceiveMemoryWarning];    
       
    24     // Release any cached data, images, etc that aren't in use.
       
    25 }
       
    26 
       
    27 // load the view programmatically; we need a splitViewController that handles a MasterViewController 
       
    28 // (which is just a UITableViewController) and a DetailViewController where we present options
       
    29 -(void) viewDidLoad {
       
    30     // init every possible controller
       
    31     splitViewController = [[UISplitViewController alloc] init];
       
    32     detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
       
    33     masterViewController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain];
       
    34     UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
       
    35 
       
    36     // set attributes
       
    37     masterViewController.detailViewController = detailViewController;
       
    38     splitViewController.viewControllers = [NSArray arrayWithObjects:navigationController, detailViewController, nil];
       
    39 	splitViewController.delegate = detailViewController;
       
    40     
       
    41     // add view to main controller
       
    42     [self.view addSubview:splitViewController.view];
       
    43      
       
    44     [super viewDidLoad];
       
    45 }
       
    46 
       
    47 -(void) dealloc {
       
    48     [detailViewController release];
       
    49     [masterViewController release];
       
    50     [splitViewController release];
       
    51     [super dealloc];
       
    52 }
       
    53 
       
    54 
       
    55 @end