author | sheepluva |
Mon, 05 Sep 2011 15:11:46 +0200 | |
changeset 5782 | 64902ceab3e2 |
parent 5219 | 9e2a17ab178b |
child 6000 | dbcebcd3d79f |
permissions | -rw-r--r-- |
3829 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
4976 | 3 |
* Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com> |
3829 | 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 |
|
4356 | 27 |
@synthesize activeController, rightNavController, splitViewRootController; |
3547 | 28 |
|
29 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
|
30 |
return rotationManager(interfaceOrientation); |
|
31 |
} |
|
32 |
||
33 |
-(void) didReceiveMemoryWarning { |
|
3701 | 34 |
if (self.activeController.view.superview == nil) |
35 |
self.activeController = nil; |
|
3547 | 36 |
MSG_MEMCLEAN(); |
3971 | 37 |
[super didReceiveMemoryWarning]; |
3547 | 38 |
} |
39 |
||
3697 | 40 |
// load the view programmatically; we need a splitViewController that handles a MasterViewController |
3547 | 41 |
// (which is just a UITableViewController) and a DetailViewController where we present options |
42 |
-(void) viewDidLoad { |
|
3701 | 43 |
CGRect rect = [[UIScreen mainScreen] bounds]; |
44 |
self.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
|
3547 | 45 |
|
3701 | 46 |
if (self.activeController == nil) { |
47 |
MasterViewController *rightController = [[MasterViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
5219 | 48 |
rightController.rootController = self; |
3701 | 49 |
rightController.targetController = nil; |
50 |
self.activeController = rightController; |
|
51 |
[rightController release]; |
|
52 |
} |
|
4356 | 53 |
self.rightNavController = [[UINavigationController alloc] initWithRootViewController:self.activeController]; |
3701 | 54 |
|
3996 | 55 |
if (IS_IPAD()) { |
3701 | 56 |
MasterViewController *leftController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain]; |
5219 | 57 |
leftController.rootController = self; |
3701 | 58 |
leftController.targetController = self.activeController; |
59 |
UINavigationController *leftNavController = [[UINavigationController alloc] initWithRootViewController:leftController]; |
|
60 |
[leftController release]; |
|
3697 | 61 |
|
4356 | 62 |
self.splitViewRootController = [[UISplitViewController alloc] init]; |
63 |
self.splitViewRootController.delegate = nil; |
|
64 |
self.splitViewRootController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
|
65 |
self.splitViewRootController.viewControllers = [NSArray arrayWithObjects: leftNavController, self.rightNavController, nil]; |
|
3701 | 66 |
[leftNavController release]; |
4356 | 67 |
[self.rightNavController release]; |
3697 | 68 |
|
3547 | 69 |
// add view to main controller |
4356 | 70 |
[self.view addSubview:self.splitViewRootController.view]; |
3547 | 71 |
} else { |
4356 | 72 |
self.rightNavController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
73 |
[self.view addSubview:self.rightNavController.view]; |
|
3547 | 74 |
} |
75 |
||
76 |
[super viewDidLoad]; |
|
77 |
} |
|
3697 | 78 |
|
5219 | 79 |
-(void) dismissModalViewControllerAnimated:(BOOL)animated { |
80 |
playSound(@"backSound"); |
|
81 |
[self.parentViewController dismissModalViewControllerAnimated:YES]; |
|
82 |
} |
|
83 |
||
3547 | 84 |
-(void) viewDidUnload { |
3701 | 85 |
self.activeController = nil; |
4356 | 86 |
self.rightNavController = nil; |
87 |
self.splitViewRootController = 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
|
88 |
MSG_DIDUNLOAD(); |
3547 | 89 |
[super viewDidUnload]; |
90 |
} |
|
91 |
||
92 |
-(void) dealloc { |
|
5208 | 93 |
releaseAndNil(activeController); |
94 |
releaseAndNil(rightNavController); |
|
95 |
releaseAndNil(splitViewRootController); |
|
3547 | 96 |
[super dealloc]; |
97 |
} |
|
98 |
||
99 |
#pragma mark - |
|
100 |
#pragma mark additional methods as we're using a UINavigationController programmatically |
|
101 |
// see http://davidebenini.it/2009/01/03/viewwillappear-not-being-called-inside-a-uinavigationcontroller/ |
|
102 |
-(void) viewWillAppear:(BOOL)animated { |
|
103 |
[super viewWillAppear:animated]; |
|
3701 | 104 |
[self.activeController.navigationController viewWillAppear:animated]; |
3547 | 105 |
} |
106 |
||
107 |
-(void) viewWillDisappear:(BOOL)animated { |
|
108 |
[super viewWillDisappear:animated]; |
|
3701 | 109 |
[self.activeController.navigationController viewWillDisappear:animated]; |
3547 | 110 |
} |
111 |
||
112 |
-(void) viewDidAppear:(BOOL)animated { |
|
113 |
[super viewDidLoad]; |
|
3701 | 114 |
[self.activeController.navigationController viewDidAppear:animated]; |
3547 | 115 |
} |
116 |
||
117 |
-(void) viewDidDisappear:(BOOL)animated { |
|
118 |
[super viewDidUnload]; |
|
3701 | 119 |
[self.activeController.navigationController viewDidDisappear:animated]; |
3547 | 120 |
} |
121 |
||
122 |
||
123 |
@end |