author | koda |
Sat, 31 Jul 2010 11:24:53 +0200 | |
changeset 3697 | d5b30d6373fc |
parent 3662 | a44406f4369b |
child 3701 | 8c449776ebe6 |
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 |
|
15 |
||
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. |
25 |
if (detailViewController.view.superview == nil) |
|
26 |
detailViewController = nil; |
|
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 { |
|
33 |
detailViewController = [[DetailViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
34 |
UINavigationController *detailedNavController = [[UINavigationController alloc] initWithRootViewController:detailViewController]; |
|
35 |
[detailViewController release]; |
|
36 |
||
37 |
CGRect rect = [[UIScreen mainScreen] bounds]; |
|
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
|
38 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { |
3547 | 39 |
self.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
3697 | 40 |
|
3547 | 41 |
UISplitViewController *splitViewRootController = [[UISplitViewController alloc] init]; |
42 |
splitViewRootController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
|
3697 | 43 |
|
3547 | 44 |
MasterViewController *masterViewController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain]; |
45 |
UINavigationController *mainNavController = [[UINavigationController alloc] initWithRootViewController:masterViewController]; |
|
46 |
[masterViewController release]; |
|
47 |
||
48 |
splitViewRootController.delegate = detailViewController; |
|
3697 | 49 |
masterViewController.detailViewController = detailViewController; |
3547 | 50 |
splitViewRootController.viewControllers = [NSArray arrayWithObjects: mainNavController, detailedNavController, nil]; |
51 |
[mainNavController release]; |
|
52 |
[detailedNavController release]; |
|
3697 | 53 |
|
3547 | 54 |
// add view to main controller |
55 |
[self.view addSubview:splitViewRootController.view]; |
|
56 |
} else { |
|
57 |
[self.view addSubview:detailedNavController.view]; |
|
58 |
} |
|
59 |
||
60 |
[super viewDidLoad]; |
|
61 |
} |
|
3697 | 62 |
|
3547 | 63 |
-(void) viewDidUnload { |
64 |
detailViewController = 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
|
65 |
MSG_DIDUNLOAD(); |
3547 | 66 |
[super viewDidUnload]; |
67 |
} |
|
68 |
||
69 |
-(void) dealloc { |
|
70 |
[detailViewController release]; |
|
71 |
[super dealloc]; |
|
72 |
} |
|
73 |
||
74 |
#pragma mark - |
|
75 |
#pragma mark additional methods as we're using a UINavigationController programmatically |
|
76 |
// see http://davidebenini.it/2009/01/03/viewwillappear-not-being-called-inside-a-uinavigationcontroller/ |
|
77 |
-(void) viewWillAppear:(BOOL)animated { |
|
78 |
[super viewWillAppear:animated]; |
|
79 |
[detailViewController.navigationController viewWillAppear:animated]; |
|
80 |
} |
|
81 |
||
82 |
-(void) viewWillDisappear:(BOOL)animated { |
|
83 |
[super viewWillDisappear:animated]; |
|
84 |
[detailViewController.navigationController viewWillDisappear:animated]; |
|
85 |
} |
|
86 |
||
87 |
-(void) viewDidAppear:(BOOL)animated { |
|
88 |
[super viewDidLoad]; |
|
89 |
[detailViewController.navigationController viewDidAppear:animated]; |
|
90 |
} |
|
91 |
||
92 |
-(void) viewDidDisappear:(BOOL)animated { |
|
93 |
[super viewDidUnload]; |
|
94 |
[detailViewController.navigationController viewDidDisappear:animated]; |
|
95 |
} |
|
96 |
||
97 |
||
98 |
@end |