author | nemo |
Sun, 10 Oct 2010 20:16:17 -0400 | |
changeset 3951 | c9a63db3e603 |
parent 3829 | 81db3c85784b |
child 3971 | 5c82ee165ed5 |
permissions | -rw-r--r-- |
3829 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
3 |
* Copyright (c) 2009-2010 Vittorio Giovara <vittorio.giovara@gmail.com> |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
17 |
* |
|
18 |
* File created on 27/03/2010. |
|
19 |
*/ |
|
20 |
||
3547 | 21 |
|
22 |
#import "SplitViewRootController.h" |
|
23 |
#import "MasterViewController.h" |
|
24 |
#import "CommodityFunctions.h" |
|
25 |
||
26 |
@implementation SplitViewRootController |
|
3701 | 27 |
@synthesize activeController; |
3547 | 28 |
|
29 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
|
30 |
return rotationManager(interfaceOrientation); |
|
31 |
} |
|
32 |
||
33 |
-(void) didReceiveMemoryWarning { |
|
34 |
// Releases the view if it doesn't have a superview. |
|
3697 | 35 |
[super didReceiveMemoryWarning]; |
3547 | 36 |
// Release any cached data, images, etc that aren't in use. |
3701 | 37 |
if (self.activeController.view.superview == nil) |
38 |
self.activeController = nil; |
|
3547 | 39 |
MSG_MEMCLEAN(); |
40 |
} |
|
41 |
||
3697 | 42 |
// load the view programmatically; we need a splitViewController that handles a MasterViewController |
3547 | 43 |
// (which is just a UITableViewController) and a DetailViewController where we present options |
44 |
-(void) viewDidLoad { |
|
3701 | 45 |
CGRect rect = [[UIScreen mainScreen] bounds]; |
46 |
self.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
|
3547 | 47 |
|
3701 | 48 |
if (self.activeController == nil) { |
49 |
MasterViewController *rightController = [[MasterViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
50 |
rightController.targetController = nil; |
|
51 |
self.activeController = rightController; |
|
52 |
[rightController release]; |
|
53 |
} |
|
54 |
UINavigationController *rightNavController = [[UINavigationController alloc] initWithRootViewController:self.activeController]; |
|
55 |
||
3662
a44406f4369b
polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents:
3547
diff
changeset
|
56 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { |
3701 | 57 |
MasterViewController *leftController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain]; |
58 |
leftController.targetController = self.activeController; |
|
59 |
UINavigationController *leftNavController = [[UINavigationController alloc] initWithRootViewController:leftController]; |
|
60 |
[leftController release]; |
|
3697 | 61 |
|
3547 | 62 |
UISplitViewController *splitViewRootController = [[UISplitViewController alloc] init]; |
3701 | 63 |
splitViewRootController.delegate = nil; |
3547 | 64 |
splitViewRootController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
3701 | 65 |
splitViewRootController.viewControllers = [NSArray arrayWithObjects: leftNavController, rightNavController, nil]; |
66 |
[leftNavController release]; |
|
67 |
[rightNavController release]; |
|
3697 | 68 |
|
3547 | 69 |
// add view to main controller |
70 |
[self.view addSubview:splitViewRootController.view]; |
|
71 |
} else { |
|
3701 | 72 |
rightNavController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
73 |
[self.view addSubview:rightNavController.view]; |
|
3547 | 74 |
} |
75 |
||
76 |
[super viewDidLoad]; |
|
77 |
} |
|
3697 | 78 |
|
3547 | 79 |
-(void) viewDidUnload { |
3701 | 80 |
self.activeController = nil; |
3662
a44406f4369b
polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents:
3547
diff
changeset
|
81 |
MSG_DIDUNLOAD(); |
3547 | 82 |
[super viewDidUnload]; |
83 |
} |
|
84 |
||
85 |
-(void) dealloc { |
|
3701 | 86 |
[self.activeController release]; |
3547 | 87 |
[super dealloc]; |
88 |
} |
|
89 |
||
90 |
#pragma mark - |
|
91 |
#pragma mark additional methods as we're using a UINavigationController programmatically |
|
92 |
// see http://davidebenini.it/2009/01/03/viewwillappear-not-being-called-inside-a-uinavigationcontroller/ |
|
93 |
-(void) viewWillAppear:(BOOL)animated { |
|
94 |
[super viewWillAppear:animated]; |
|
3701 | 95 |
[self.activeController.navigationController viewWillAppear:animated]; |
3547 | 96 |
} |
97 |
||
98 |
-(void) viewWillDisappear:(BOOL)animated { |
|
99 |
[super viewWillDisappear:animated]; |
|
3701 | 100 |
[self.activeController.navigationController viewWillDisappear:animated]; |
3547 | 101 |
} |
102 |
||
103 |
-(void) viewDidAppear:(BOOL)animated { |
|
104 |
[super viewDidLoad]; |
|
3701 | 105 |
[self.activeController.navigationController viewDidAppear:animated]; |
3547 | 106 |
} |
107 |
||
108 |
-(void) viewDidDisappear:(BOOL)animated { |
|
109 |
[super viewDidUnload]; |
|
3701 | 110 |
[self.activeController.navigationController viewDidDisappear:animated]; |
3547 | 111 |
} |
112 |
||
113 |
||
114 |
@end |