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