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