author | koda |
Sat, 01 Oct 2011 02:49:40 +0200 | |
changeset 6075 | 0173cd44c3bc |
parent 6074 | project_files/HedgewarsMobile/Classes/SplitViewRootController.m@047eaed35cbb |
child 6076 | e1b4771f6472 |
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 |
|
6075
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
22 |
#import "SettingsContainerViewController.h" |
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
23 |
#import "SettingsBaseViewController.h" |
3547 | 24 |
#import "CommodityFunctions.h" |
25 |
||
6075
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
26 |
@implementation SettingsContainerViewController |
6074
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
27 |
@synthesize activeController, splitViewRootController; |
3547 | 28 |
|
29 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
|
30 |
return rotationManager(interfaceOrientation); |
|
31 |
} |
|
32 |
||
6074
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
33 |
|
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
34 |
-(void) viewDidLoad { |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
35 |
CGRect rect = [[UIScreen mainScreen] bounds]; |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
36 |
self.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
37 |
|
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
38 |
if (IS_IPAD()) { |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
39 |
// the contents on the right of the splitview, setting targetController to nil to avoid creating the table |
6075
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
40 |
SettingsBaseViewController *rightController = [[SettingsBaseViewController alloc] init]; |
6074
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
41 |
rightController.targetController = nil; |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
42 |
UINavigationController *rightNavController = [[UINavigationController alloc] initWithRootViewController:rightController]; |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
43 |
[rightController release]; |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
44 |
|
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
45 |
// the contens on the left of the splitview, setting targetController that will receive push/pop actions |
6075
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
46 |
SettingsBaseViewController *leftController = [[SettingsBaseViewController alloc] init]; |
6074
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
47 |
leftController.targetController = rightNavController.topViewController; |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
48 |
UINavigationController *leftNavController = [[UINavigationController alloc] initWithRootViewController:leftController]; |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
49 |
[leftController release]; |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
50 |
|
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
51 |
self.activeController = rightNavController; |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
52 |
self.splitViewRootController = [[UISplitViewController alloc] init]; |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
53 |
self.splitViewRootController.delegate = nil; |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
54 |
self.splitViewRootController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
55 |
self.splitViewRootController.viewControllers = [NSArray arrayWithObjects: leftNavController, rightNavController, nil]; |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
56 |
[leftNavController release]; |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
57 |
[rightNavController release]; |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
58 |
|
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
59 |
// add view to main controller |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
60 |
[self.view addSubview:self.splitViewRootController.view]; |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
61 |
} else { |
6075
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
62 |
SettingsBaseViewController *baseController = [[SettingsBaseViewController alloc] init]; |
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
63 |
baseController.targetController = nil; |
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
64 |
baseController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
65 |
[self.view addSubview:baseController.view]; |
6074
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
66 |
// here setting activeController is not needed as the event is kept active by the uitabbarcontroller |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
67 |
} |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
68 |
|
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
69 |
[super viewDidLoad]; |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
70 |
} |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
71 |
|
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
72 |
#pragma mark - |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
73 |
#pragma mark Memory management |
3547 | 74 |
-(void) didReceiveMemoryWarning { |
6074
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
75 |
if (self.splitViewRootController.view.superview == nil) |
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
76 |
self.splitViewRootController = nil; |
3701 | 77 |
if (self.activeController.view.superview == nil) |
78 |
self.activeController = nil; |
|
3547 | 79 |
MSG_MEMCLEAN(); |
3971 | 80 |
[super didReceiveMemoryWarning]; |
3547 | 81 |
} |
82 |
||
83 |
-(void) viewDidUnload { |
|
3701 | 84 |
self.activeController = nil; |
4356 | 85 |
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
|
86 |
MSG_DIDUNLOAD(); |
3547 | 87 |
[super viewDidUnload]; |
88 |
} |
|
89 |
||
90 |
-(void) dealloc { |
|
5208 | 91 |
releaseAndNil(activeController); |
92 |
releaseAndNil(splitViewRootController); |
|
3547 | 93 |
[super dealloc]; |
94 |
} |
|
95 |
||
6074
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
96 |
|
3547 | 97 |
#pragma mark - |
98 |
#pragma mark additional methods as we're using a UINavigationController programmatically |
|
99 |
// see http://davidebenini.it/2009/01/03/viewwillappear-not-being-called-inside-a-uinavigationcontroller/ |
|
100 |
-(void) viewWillAppear:(BOOL)animated { |
|
101 |
[super viewWillAppear:animated]; |
|
6074
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
102 |
[self.activeController viewWillAppear:animated]; |
3547 | 103 |
} |
104 |
||
105 |
-(void) viewWillDisappear:(BOOL)animated { |
|
106 |
[super viewWillDisappear:animated]; |
|
6074
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
107 |
[self.activeController viewWillDisappear:animated]; |
3547 | 108 |
} |
109 |
||
110 |
-(void) viewDidAppear:(BOOL)animated { |
|
111 |
[super viewDidLoad]; |
|
6074
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
112 |
[self.activeController viewDidAppear:animated]; |
3547 | 113 |
} |
114 |
||
115 |
-(void) viewDidDisappear:(BOOL)animated { |
|
116 |
[super viewDidUnload]; |
|
6074
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
117 |
[self.activeController viewDidDisappear:animated]; |
3547 | 118 |
} |
119 |
||
120 |
||
121 |
@end |