cocoaTouch/SplitViewRootController.m
author koda
Thu, 17 Jun 2010 19:57:51 +0200
changeset 3513 f589230fa21b
parent 3490 016b3172b645
permissions -rw-r--r--
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive) add rotation for iphone build too make the ifrontend work again with 3.0 sdk reworked openalbridge following most of an old implementation by Smaxx and making it more modular -- now sources are limited but the memory extension and cleanup is todo nil'd many variables in engine that were causing intialization problems
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.
3490
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
    25
    if (detailViewController.view.superview == nil)
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
    26
        detailViewController = nil;
3487
b1d00f1950c8 add some memory aware code
koda
parents: 3465
diff changeset
    27
    MSG_MEMCLEAN();
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    28
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    29
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    30
// load the view programmatically; we need a splitViewController that handles a MasterViewController 
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    31
// (which is just a UITableViewController) and a DetailViewController where we present options
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    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
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    35
    [detailViewController release];
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    36
3490
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
    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
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
    39
        self.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width);
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
    40
        
3321
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    41
    Class splitViewControllerClass = NSClassFromString(@"UISplitViewController");
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    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
b290993c0810 unbreak stuff
koda
parents: 3464
diff changeset
    44
        UISplitViewController *splitViewRootController = [[UISplitViewController alloc] init];
3490
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
    45
        //splitViewRootController.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;        
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
    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
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    48
        MasterViewController *masterViewController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    49
        UINavigationController *mainNavController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
3321
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    50
        [masterViewController release];
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    51
3490
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
    52
        splitViewRootController.delegate = detailViewController;
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
    53
        masterViewController.detailViewController = detailViewController;        
3465
b290993c0810 unbreak stuff
koda
parents: 3464
diff changeset
    54
        splitViewRootController.viewControllers = [NSArray arrayWithObjects: mainNavController, detailedNavController, nil];
3305
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
        
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    58
        // add view to main controller
3490
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
    59
        [self.view addSubview:splitViewRootController.view];
3465
b290993c0810 unbreak stuff
koda
parents: 3464
diff changeset
    60
#endif
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    61
    } else {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    62
        [self.view addSubview:detailedNavController.view];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    63
    }
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    64
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    65
    [super viewDidLoad];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    66
}
3321
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    67
         
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    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
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    70
    [super viewDidUnload];
3490
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
    71
    MSG_DIDUNLOAD();
3321
988e39ef3c20 rewrote a couple of things i didn't like
koda
parents: 3312
diff changeset
    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
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    74
-(void) dealloc {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    75
    [detailViewController release];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    76
    [super dealloc];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    77
}
3490
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
    78
-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
    79
    [detailViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
    80
}
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    81
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    82
#pragma mark -
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    83
#pragma mark additional methods as we're using a UINavigationController programmatically
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    84
// 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
    85
-(void) viewWillAppear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    86
    [super viewWillAppear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    87
    [detailViewController.navigationController viewWillAppear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    88
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    89
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    90
-(void) viewWillDisappear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    91
    [super viewWillDisappear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    92
    [detailViewController.navigationController viewWillDisappear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    93
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    94
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    95
-(void) viewDidAppear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    96
    [super viewDidLoad];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    97
    [detailViewController.navigationController viewDidAppear:animated];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    98
}
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
    99
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   100
-(void) viewDidDisappear:(BOOL)animated {
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   101
    [super viewDidUnload];
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   102
    [detailViewController.navigationController viewDidDisappear:animated];
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
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   105
91074496d5c9 merged code from ipad and iphone frontends
koda
parents:
diff changeset
   106
@end