author | koda |
Fri, 02 Apr 2010 12:38:36 +0000 | |
changeset 3250 | d5cd1a617123 |
parent 3113 | 2829ea0dd47c |
child 3270 | 9bd8fb1707b9 |
permissions | -rw-r--r-- |
3113 | 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 |
masterViewController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain]; |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
33 |
detailViewController = [[DetailViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
34 |
|
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
35 |
UINavigationController *mainNavController = [[UINavigationController alloc] initWithRootViewController:masterViewController]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
36 |
UINavigationController *detailedNavController = [[UINavigationController alloc] initWithRootViewController:detailViewController]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
37 |
|
3113 | 38 |
// set attributes |
39 |
masterViewController.detailViewController = detailViewController; |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
40 |
splitViewController.viewControllers = [NSArray arrayWithObjects: mainNavController, detailedNavController, nil]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
41 |
[mainNavController release]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
42 |
[detailedNavController release]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
43 |
|
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
44 |
splitViewController.delegate = detailViewController; |
3113 | 45 |
|
46 |
// add view to main controller |
|
47 |
[self.view addSubview:splitViewController.view]; |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
48 |
[detailViewController release]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
49 |
[masterViewController release]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
50 |
|
3113 | 51 |
[super viewDidLoad]; |
52 |
} |
|
53 |
||
54 |
-(void) dealloc { |
|
55 |
[detailViewController release]; |
|
56 |
[masterViewController release]; |
|
57 |
[splitViewController release]; |
|
58 |
[super dealloc]; |
|
59 |
} |
|
60 |
||
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
61 |
#pragma mark - |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
62 |
#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
|
63 |
// 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
|
64 |
-(void) viewWillAppear:(BOOL)animated { |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
65 |
[super viewWillAppear:animated]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
66 |
[detailViewController.navigationController viewWillAppear:animated]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
67 |
} |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
68 |
|
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
69 |
-(void) viewWillDisappear:(BOOL)animated { |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
70 |
[super viewWillDisappear:animated]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
71 |
[detailViewController.navigationController viewWillDisappear:animated]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
72 |
} |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
73 |
|
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
74 |
-(void) viewDidAppear:(BOOL)animated { |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
75 |
[super viewDidLoad]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
76 |
[detailViewController.navigationController viewDidAppear:animated]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
77 |
} |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
78 |
|
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
79 |
-(void) viewDidDisappear:(BOOL)animated { |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
80 |
[super viewDidUnload]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
81 |
[detailViewController.navigationController viewDidDisappear:animated]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
82 |
} |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3113
diff
changeset
|
83 |
|
3113 | 84 |
|
85 |
@end |