cocoaTouch/iPad/SplitViewRootController.m
changeset 3113 2829ea0dd47c
child 3250 d5cd1a617123
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cocoaTouch/iPad/SplitViewRootController.m	Sat Mar 27 16:57:18 2010 +0000
@@ -0,0 +1,55 @@
+    //
+//  SplitViewRootController.m
+//  HedgewarsMobile
+//
+//  Created by Vittorio on 27/03/10.
+//  Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import "SplitViewRootController.h"
+#import "MasterViewController.h"
+#import "DetailViewController.h"
+
+@implementation SplitViewRootController
+@synthesize splitViewController, masterViewController, detailViewController;
+
+
+-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
+    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
+}
+
+-(void) didReceiveMemoryWarning {
+    // Releases the view if it doesn't have a superview.
+    [super didReceiveMemoryWarning];    
+    // Release any cached data, images, etc that aren't in use.
+}
+
+// load the view programmatically; we need a splitViewController that handles a MasterViewController 
+// (which is just a UITableViewController) and a DetailViewController where we present options
+-(void) viewDidLoad {
+    // init every possible controller
+    splitViewController = [[UISplitViewController alloc] init];
+    detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
+    masterViewController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain];
+    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
+
+    // set attributes
+    masterViewController.detailViewController = detailViewController;
+    splitViewController.viewControllers = [NSArray arrayWithObjects:navigationController, detailViewController, nil];
+	splitViewController.delegate = detailViewController;
+    
+    // add view to main controller
+    [self.view addSubview:splitViewController.view];
+     
+    [super viewDidLoad];
+}
+
+-(void) dealloc {
+    [detailViewController release];
+    [masterViewController release];
+    [splitViewController release];
+    [super dealloc];
+}
+
+
+@end