author | koda |
Mon, 25 Oct 2010 22:19:00 +0200 | |
changeset 3996 | eb549fd864a5 |
parent 3971 | 5c82ee165ed5 |
child 4356 | d1d26f8963a3 |
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 { |
|
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]; |
|
48 |
rightController.targetController = nil; |
|
49 |
self.activeController = rightController; |
|
50 |
[rightController release]; |
|
51 |
} |
|
52 |
UINavigationController *rightNavController = [[UINavigationController alloc] initWithRootViewController:self.activeController]; |
|
53 |
||
3996 | 54 |
if (IS_IPAD()) { |
3701 | 55 |
MasterViewController *leftController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain]; |
56 |
leftController.targetController = self.activeController; |
|
57 |
UINavigationController *leftNavController = [[UINavigationController alloc] initWithRootViewController:leftController]; |
|
58 |
[leftController release]; |
|
3697 | 59 |
|
3547 | 60 |
UISplitViewController *splitViewRootController = [[UISplitViewController alloc] init]; |
3701 | 61 |
splitViewRootController.delegate = nil; |
3547 | 62 |
splitViewRootController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
3701 | 63 |
splitViewRootController.viewControllers = [NSArray arrayWithObjects: leftNavController, rightNavController, nil]; |
64 |
[leftNavController release]; |
|
65 |
[rightNavController release]; |
|
3697 | 66 |
|
3547 | 67 |
// add view to main controller |
68 |
[self.view addSubview:splitViewRootController.view]; |
|
69 |
} else { |
|
3701 | 70 |
rightNavController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
71 |
[self.view addSubview:rightNavController.view]; |
|
3547 | 72 |
} |
73 |
||
74 |
[super viewDidLoad]; |
|
75 |
} |
|
3697 | 76 |
|
3547 | 77 |
-(void) viewDidUnload { |
3701 | 78 |
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
|
79 |
MSG_DIDUNLOAD(); |
3547 | 80 |
[super viewDidUnload]; |
81 |
} |
|
82 |
||
83 |
-(void) dealloc { |
|
3701 | 84 |
[self.activeController release]; |
3547 | 85 |
[super dealloc]; |
86 |
} |
|
87 |
||
88 |
#pragma mark - |
|
89 |
#pragma mark additional methods as we're using a UINavigationController programmatically |
|
90 |
// see http://davidebenini.it/2009/01/03/viewwillappear-not-being-called-inside-a-uinavigationcontroller/ |
|
91 |
-(void) viewWillAppear:(BOOL)animated { |
|
92 |
[super viewWillAppear:animated]; |
|
3701 | 93 |
[self.activeController.navigationController viewWillAppear:animated]; |
3547 | 94 |
} |
95 |
||
96 |
-(void) viewWillDisappear:(BOOL)animated { |
|
97 |
[super viewWillDisappear:animated]; |
|
3701 | 98 |
[self.activeController.navigationController viewWillDisappear:animated]; |
3547 | 99 |
} |
100 |
||
101 |
-(void) viewDidAppear:(BOOL)animated { |
|
102 |
[super viewDidLoad]; |
|
3701 | 103 |
[self.activeController.navigationController viewDidAppear:animated]; |
3547 | 104 |
} |
105 |
||
106 |
-(void) viewDidDisappear:(BOOL)animated { |
|
107 |
[super viewDidUnload]; |
|
3701 | 108 |
[self.activeController.navigationController viewDidDisappear:animated]; |
3547 | 109 |
} |
110 |
||
111 |
||
112 |
@end |