cocoaTouch/SplitViewRootController.m
author smxx
Fri, 07 May 2010 13:04:01 +0000
changeset 3446 1be74e601960
parent 3405 8fdb08497bf1
child 3464 cdb0ddeb38ba
permissions -rw-r--r--
Graphics: * Added a team colored tophat as a "fixed colors with tinted areas" example
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     1
    //
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     2
//  SplitViewRootController.m
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     3
//  HedgewarsMobile
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     4
//
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     5
//  Created by Vittorio on 27/03/10.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     7
//
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     8
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
     9
#import "SplitViewRootController.h"
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    10
#import "MasterViewController.h"
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    11
#import "DetailViewController.h"
3335
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3332
diff changeset
    12
#import "CommodityFunctions.h"
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    13
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    14
@implementation SplitViewRootController
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    15
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    16
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    17
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
3335
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3332
diff changeset
    18
    return rotationManager(interfaceOrientation);
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    19
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    20
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    21
-(void) didReceiveMemoryWarning {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    22
    // Releases the view if it doesn't have a superview.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    23
    [super didReceiveMemoryWarning];    
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    24
    // Release any cached data, images, etc that aren't in use.
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    25
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    26
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    27
// load the view programmatically; we need a splitViewController that handles a MasterViewController 
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    28
// (which is just a UITableViewController) and a DetailViewController where we present options
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    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
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    32
    [detailViewController release];
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    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
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    37
    id splitViewRootController;
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    38
    
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    39
    Class splitViewControllerClass = NSClassFromString(@"UISplitViewController");
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    40
    if (splitViewControllerClass) {
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    41
        splitViewRootController = [[splitViewControllerClass alloc] init];
3352
ac5d14a35482 complete previews on the team settings
koda
parents: 3335
diff changeset
    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
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    45
        MasterViewController *masterViewController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    46
        
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    47
        UINavigationController *mainNavController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
3321
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    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
8fdb08497bf1 js' patch that restores Vsync on snow leopard
koda
parents: 3374
diff changeset
    50
        //[splitViewRootController setDelegate:detailViewController];
8fdb08497bf1 js' patch that restores Vsync on snow leopard
koda
parents: 3374
diff changeset
    51
        
3321
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    52
        [masterViewController release];
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    53
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    54
        [splitViewRootController setViewControllers:[NSArray arrayWithObjects: mainNavController, detailedNavController, nil]];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    55
        [mainNavController release];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    56
        [detailedNavController release];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    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
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    59
        [detailViewController release];
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    60
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    61
        // add view to main controller
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    62
        [self.view addSubview:[splitViewRootController view]];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    63
    } else {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    64
        [self.view addSubview:detailedNavController.view];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    65
    }
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    66
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    67
    [super viewDidLoad];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    68
}
3321
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    69
         
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    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
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    72
    [super viewDidUnload];
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    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
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    75
-(void) dealloc {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    76
    [detailViewController release];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    77
    [super dealloc];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    78
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    79
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    80
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    81
#pragma mark additional methods as we're using a UINavigationController programmatically
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    82
// see http://davidebenini.it/2009/01/03/viewwillappear-not-being-called-inside-a-uinavigationcontroller/
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    83
-(void) viewWillAppear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    84
    [super viewWillAppear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    85
    [detailViewController.navigationController viewWillAppear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    86
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    87
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    88
-(void) viewWillDisappear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    89
    [super viewWillDisappear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    90
    [detailViewController.navigationController viewWillDisappear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    91
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    92
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    93
-(void) viewDidAppear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    94
    [super viewDidLoad];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    95
    [detailViewController.navigationController viewDidAppear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    96
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    97
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    98
-(void) viewDidDisappear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    99
    [super viewDidUnload];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   100
    [detailViewController.navigationController viewDidDisappear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   101
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   102
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   103
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   104
@end