author | nemo |
Sun, 20 Jun 2010 22:35:10 -0400 | |
changeset 3526 | a1d2180fef42 |
parent 3514 | 59dbd31e9953 |
child 3535 | 9e78c1f3d8d8 |
permissions | -rw-r--r-- |
3305 | 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" |
|
3335 | 12 |
#import "CommodityFunctions.h" |
3305 | 13 |
|
14 |
@implementation SplitViewRootController |
|
15 |
||
16 |
||
17 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
|
3335 | 18 |
return rotationManager(interfaceOrientation); |
3305 | 19 |
} |
20 |
||
21 |
-(void) didReceiveMemoryWarning { |
|
22 |
// Releases the view if it doesn't have a superview. |
|
23 |
[super didReceiveMemoryWarning]; |
|
24 |
// Release any cached data, images, etc that aren't in use. |
|
3490 | 25 |
if (detailViewController.view.superview == nil) |
26 |
detailViewController = nil; |
|
3487 | 27 |
MSG_MEMCLEAN(); |
3305 | 28 |
} |
29 |
||
30 |
// load the view programmatically; we need a splitViewController that handles a MasterViewController |
|
31 |
// (which is just a UITableViewController) and a DetailViewController where we present options |
|
32 |
-(void) viewDidLoad { |
|
3374
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
33 |
detailViewController = [[DetailViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
34 |
UINavigationController *detailedNavController = [[UINavigationController alloc] initWithRootViewController:detailViewController]; |
3321 | 35 |
[detailViewController release]; |
36 |
||
3490 | 37 |
CGRect rect = [[UIScreen mainScreen] bounds]; |
3374
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
38 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) |
3490 | 39 |
self.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
40 |
||
3321 | 41 |
Class splitViewControllerClass = NSClassFromString(@"UISplitViewController"); |
42 |
if (splitViewControllerClass) { |
|
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3490
diff
changeset
|
43 |
#if __IPHONE_3_2 |
3465 | 44 |
UISplitViewController *splitViewRootController = [[UISplitViewController alloc] init]; |
3490 | 45 |
//splitViewRootController.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; |
46 |
splitViewRootController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width); |
|
3374
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
47 |
|
3321 | 48 |
MasterViewController *masterViewController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain]; |
3305 | 49 |
UINavigationController *mainNavController = [[UINavigationController alloc] initWithRootViewController:masterViewController]; |
3321 | 50 |
[masterViewController release]; |
51 |
||
3490 | 52 |
splitViewRootController.delegate = detailViewController; |
53 |
masterViewController.detailViewController = detailViewController; |
|
3465 | 54 |
splitViewRootController.viewControllers = [NSArray arrayWithObjects: mainNavController, detailedNavController, nil]; |
3305 | 55 |
[mainNavController release]; |
56 |
[detailedNavController release]; |
|
57 |
||
58 |
// add view to main controller |
|
3490 | 59 |
[self.view addSubview:splitViewRootController.view]; |
3465 | 60 |
#endif |
3305 | 61 |
} else { |
62 |
[self.view addSubview:detailedNavController.view]; |
|
63 |
} |
|
64 |
||
65 |
[super viewDidLoad]; |
|
66 |
} |
|
3321 | 67 |
|
68 |
-(void) viewDidUnload { |
|
3374
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
69 |
detailViewController = nil; |
3321 | 70 |
[super viewDidUnload]; |
3490 | 71 |
MSG_DIDUNLOAD(); |
3321 | 72 |
} |
3374
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
73 |
|
3305 | 74 |
-(void) dealloc { |
75 |
[detailViewController release]; |
|
76 |
[super dealloc]; |
|
77 |
} |
|
3490 | 78 |
-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ |
79 |
[detailViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; |
|
80 |
} |
|
3305 | 81 |
|
82 |
#pragma mark - |
|
83 |
#pragma mark additional methods as we're using a UINavigationController programmatically |
|
84 |
// see http://davidebenini.it/2009/01/03/viewwillappear-not-being-called-inside-a-uinavigationcontroller/ |
|
85 |
-(void) viewWillAppear:(BOOL)animated { |
|
86 |
[super viewWillAppear:animated]; |
|
87 |
[detailViewController.navigationController viewWillAppear:animated]; |
|
88 |
} |
|
89 |
||
90 |
-(void) viewWillDisappear:(BOOL)animated { |
|
91 |
[super viewWillDisappear:animated]; |
|
92 |
[detailViewController.navigationController viewWillDisappear:animated]; |
|
93 |
} |
|
94 |
||
95 |
-(void) viewDidAppear:(BOOL)animated { |
|
96 |
[super viewDidLoad]; |
|
97 |
[detailViewController.navigationController viewDidAppear:animated]; |
|
98 |
} |
|
99 |
||
100 |
-(void) viewDidDisappear:(BOOL)animated { |
|
101 |
[super viewDidUnload]; |
|
102 |
[detailViewController.navigationController viewDidDisappear:animated]; |
|
103 |
} |
|
104 |
||
105 |
||
106 |
@end |