author | smxx |
Fri, 07 May 2010 13:04:01 +0000 | |
changeset 3446 | 1be74e601960 |
parent 3405 | 8fdb08497bf1 |
child 3464 | cdb0ddeb38ba |
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. |
|
25 |
} |
|
26 |
||
27 |
// load the view programmatically; we need a splitViewController that handles a MasterViewController |
|
28 |
// (which is just a UITableViewController) and a DetailViewController where we present options |
|
29 |
-(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
|
30 |
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
|
31 |
UINavigationController *detailedNavController = [[UINavigationController alloc] initWithRootViewController:detailViewController]; |
3321 | 32 |
[detailViewController release]; |
33 |
||
3374
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
34 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) |
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
35 |
self.view.frame = CGRectMake(0, 0, 1024, 768); |
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
36 |
|
3321 | 37 |
id splitViewRootController; |
38 |
||
39 |
Class splitViewControllerClass = NSClassFromString(@"UISplitViewController"); |
|
40 |
if (splitViewControllerClass) { |
|
41 |
splitViewRootController = [[splitViewControllerClass alloc] init]; |
|
3352 | 42 |
//[[splitViewRootController view] setAutoresizingMask: UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth]; |
3374
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
43 |
|
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
44 |
[[splitViewRootController view] setFrame:CGRectMake(0, 0, 1024, 768)]; |
3321 | 45 |
MasterViewController *masterViewController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain]; |
3305 | 46 |
|
47 |
UINavigationController *mainNavController = [[UINavigationController alloc] initWithRootViewController:masterViewController]; |
|
3321 | 48 |
|
3374
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
49 |
masterViewController.detailViewController = detailViewController; |
3405 | 50 |
//[splitViewRootController setDelegate:detailViewController]; |
51 |
||
3321 | 52 |
[masterViewController release]; |
53 |
||
3305 | 54 |
[splitViewRootController setViewControllers:[NSArray arrayWithObjects: mainNavController, detailedNavController, nil]]; |
55 |
[mainNavController release]; |
|
56 |
[detailedNavController release]; |
|
57 |
||
3374
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
58 |
[splitViewRootController setDelegate:detailViewController]; |
3321 | 59 |
[detailViewController release]; |
60 |
||
3305 | 61 |
// add view to main controller |
62 |
[self.view addSubview:[splitViewRootController view]]; |
|
63 |
} else { |
|
64 |
[self.view addSubview:detailedNavController.view]; |
|
65 |
} |
|
66 |
||
67 |
[super viewDidLoad]; |
|
68 |
} |
|
3321 | 69 |
|
70 |
-(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
|
71 |
detailViewController = nil; |
3321 | 72 |
[super viewDidUnload]; |
73 |
} |
|
3374
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
74 |
|
3305 | 75 |
-(void) dealloc { |
76 |
[detailViewController release]; |
|
77 |
[super dealloc]; |
|
78 |
} |
|
79 |
||
80 |
#pragma mark - |
|
81 |
#pragma mark additional methods as we're using a UINavigationController programmatically |
|
82 |
// see http://davidebenini.it/2009/01/03/viewwillappear-not-being-called-inside-a-uinavigationcontroller/ |
|
83 |
-(void) viewWillAppear:(BOOL)animated { |
|
84 |
[super viewWillAppear:animated]; |
|
85 |
[detailViewController.navigationController viewWillAppear:animated]; |
|
86 |
} |
|
87 |
||
88 |
-(void) viewWillDisappear:(BOOL)animated { |
|
89 |
[super viewWillDisappear:animated]; |
|
90 |
[detailViewController.navigationController viewWillDisappear:animated]; |
|
91 |
} |
|
92 |
||
93 |
-(void) viewDidAppear:(BOOL)animated { |
|
94 |
[super viewDidLoad]; |
|
95 |
[detailViewController.navigationController viewDidAppear:animated]; |
|
96 |
} |
|
97 |
||
98 |
-(void) viewDidDisappear:(BOOL)animated { |
|
99 |
[super viewDidUnload]; |
|
100 |
[detailViewController.navigationController viewDidDisappear:animated]; |
|
101 |
} |
|
102 |
||
103 |
||
104 |
@end |