cocoaTouch/iPad/SplitViewRootController.m
author koda
Fri, 02 Apr 2010 22:44:14 +0000
changeset 3270 9bd8fb1707b9
parent 3250 d5cd1a617123
permissions -rw-r--r--
initial support for hat selection on the ifrontend
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];
3270
9bd8fb1707b9 initial support for hat selection on the ifrontend
koda
parents: 3250
diff changeset
    32
    CGRect screensize = [[UIScreen mainScreen] bounds];
9bd8fb1707b9 initial support for hat selection on the ifrontend
koda
parents: 3250
diff changeset
    33
    splitViewController.view.frame = CGRectMake(0, 0, screensize.size.height, screensize.size.width);
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    34
    masterViewController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain];
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    35
    detailViewController = [[DetailViewController alloc] initWithStyle:UITableViewStyleGrouped];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    36
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    37
    UINavigationController *mainNavController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    38
    UINavigationController *detailedNavController = [[UINavigationController alloc] initWithRootViewController:detailViewController];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    39
    
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    40
    // set attributes
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    41
    masterViewController.detailViewController = detailViewController;
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    42
    splitViewController.viewControllers = [NSArray arrayWithObjects: mainNavController, detailedNavController, nil];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    43
    [mainNavController release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    44
    [detailedNavController release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    45
	
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    46
    splitViewController.delegate = detailViewController;
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    47
    
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    48
    // add view to main controller
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    49
    [self.view addSubview:splitViewController.view];
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    50
    [detailViewController release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    51
    [masterViewController release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    52
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    53
    [super viewDidLoad];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    54
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    55
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    56
-(void) dealloc {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    57
    [detailViewController release];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    58
    [masterViewController release];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    59
    [splitViewController release];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    60
    [super dealloc];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    61
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    62
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    63
#pragma mark -
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    64
#pragma mark additional methods as we're using a UINavigationController programmatically
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    65
// see http://davidebenini.it/2009/01/03/viewwillappear-not-being-called-inside-a-uinavigationcontroller/
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    66
-(void) viewWillAppear:(BOOL)animated {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    67
    [super viewWillAppear:animated];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    68
    [detailViewController.navigationController viewWillAppear:animated];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    69
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    70
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    71
-(void) viewWillDisappear:(BOOL)animated {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    72
    [super viewWillDisappear:animated];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    73
    [detailViewController.navigationController viewWillDisappear:animated];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    74
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    75
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    76
-(void) viewDidAppear:(BOOL)animated {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    77
    [super viewDidLoad];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    78
    [detailViewController.navigationController viewDidAppear:animated];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    79
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    80
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    81
-(void) viewDidDisappear:(BOOL)animated {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    82
    [super viewDidUnload];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    83
    [detailViewController.navigationController viewDidDisappear:animated];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    84
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3113
diff changeset
    85
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    86
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    87
@end