author | koda |
Mon, 30 Aug 2010 05:42:03 +0200 | |
changeset 3791 | 98072b3871c1 |
parent 3783 | 8e9daf967406 |
child 3829 | 81db3c85784b |
permissions | -rw-r--r-- |
3547 | 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 "CommodityFunctions.h" |
|
12 |
||
13 |
@implementation SplitViewRootController |
|
3701 | 14 |
@synthesize activeController; |
3547 | 15 |
|
16 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
|
17 |
return rotationManager(interfaceOrientation); |
|
18 |
} |
|
19 |
||
20 |
-(void) didReceiveMemoryWarning { |
|
21 |
// Releases the view if it doesn't have a superview. |
|
3697 | 22 |
[super didReceiveMemoryWarning]; |
3547 | 23 |
// Release any cached data, images, etc that aren't in use. |
3701 | 24 |
if (self.activeController.view.superview == nil) |
25 |
self.activeController = nil; |
|
3547 | 26 |
MSG_MEMCLEAN(); |
27 |
} |
|
28 |
||
3697 | 29 |
// load the view programmatically; we need a splitViewController that handles a MasterViewController |
3547 | 30 |
// (which is just a UITableViewController) and a DetailViewController where we present options |
31 |
-(void) viewDidLoad { |
|
3701 | 32 |
CGRect rect = [[UIScreen mainScreen] bounds]; |
33 |
self.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
|
3547 | 34 |
|
3701 | 35 |
if (self.activeController == nil) { |
36 |
MasterViewController *rightController = [[MasterViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
37 |
rightController.targetController = nil; |
|
38 |
self.activeController = rightController; |
|
39 |
[rightController release]; |
|
40 |
} |
|
41 |
UINavigationController *rightNavController = [[UINavigationController alloc] initWithRootViewController:self.activeController]; |
|
42 |
||
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
|
43 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { |
3701 | 44 |
MasterViewController *leftController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain]; |
45 |
leftController.targetController = self.activeController; |
|
46 |
UINavigationController *leftNavController = [[UINavigationController alloc] initWithRootViewController:leftController]; |
|
47 |
[leftController release]; |
|
3697 | 48 |
|
3547 | 49 |
UISplitViewController *splitViewRootController = [[UISplitViewController alloc] init]; |
3701 | 50 |
splitViewRootController.delegate = nil; |
3547 | 51 |
splitViewRootController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
3701 | 52 |
splitViewRootController.viewControllers = [NSArray arrayWithObjects: leftNavController, rightNavController, nil]; |
53 |
[leftNavController release]; |
|
54 |
[rightNavController release]; |
|
3697 | 55 |
|
3547 | 56 |
// add view to main controller |
57 |
[self.view addSubview:splitViewRootController.view]; |
|
58 |
} else { |
|
3701 | 59 |
rightNavController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
60 |
[self.view addSubview:rightNavController.view]; |
|
3547 | 61 |
} |
62 |
||
63 |
[super viewDidLoad]; |
|
64 |
} |
|
3697 | 65 |
|
3547 | 66 |
-(void) viewDidUnload { |
3701 | 67 |
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
|
68 |
MSG_DIDUNLOAD(); |
3547 | 69 |
[super viewDidUnload]; |
70 |
} |
|
71 |
||
72 |
-(void) dealloc { |
|
3701 | 73 |
[self.activeController release]; |
3547 | 74 |
[super dealloc]; |
75 |
} |
|
76 |
||
77 |
#pragma mark - |
|
78 |
#pragma mark additional methods as we're using a UINavigationController programmatically |
|
79 |
// see http://davidebenini.it/2009/01/03/viewwillappear-not-being-called-inside-a-uinavigationcontroller/ |
|
80 |
-(void) viewWillAppear:(BOOL)animated { |
|
81 |
[super viewWillAppear:animated]; |
|
3701 | 82 |
[self.activeController.navigationController viewWillAppear:animated]; |
3547 | 83 |
} |
84 |
||
85 |
-(void) viewWillDisappear:(BOOL)animated { |
|
86 |
[super viewWillDisappear:animated]; |
|
3701 | 87 |
[self.activeController.navigationController viewWillDisappear:animated]; |
3547 | 88 |
} |
89 |
||
90 |
-(void) viewDidAppear:(BOOL)animated { |
|
91 |
[super viewDidLoad]; |
|
3701 | 92 |
[self.activeController.navigationController viewDidAppear:animated]; |
3547 | 93 |
} |
94 |
||
95 |
-(void) viewDidDisappear:(BOOL)animated { |
|
96 |
[super viewDidUnload]; |
|
3701 | 97 |
[self.activeController.navigationController viewDidDisappear:animated]; |
3547 | 98 |
} |
99 |
||
100 |
||
101 |
@end |