cocoaTouch/iPad/DetailViewController.m
author koda
Fri, 02 Apr 2010 22:44:14 +0000
changeset 3270 9bd8fb1707b9
parent 3253 b0b1b1310b7e
permissions -rw-r--r--
initial support for hat selection on the ifrontend
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     1
    //
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     2
//  DetailViewController.m
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     3
//  HedgewarsMobile
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     4
//
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     5
//  Created by Vittorio on 27/03/10.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     7
//
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     8
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     9
#import "DetailViewController.h"
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    10
#import "TeamSettingsViewController.h"
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    11
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    12
@implementation DetailViewController
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    13
@synthesize popoverController, detailItem, controllers;
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    14
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    15
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    16
- (void)viewDidLoad {
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    17
    self.title =@"First";
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    18
    NSMutableArray *array= [[NSMutableArray alloc] init];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    19
3251
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    20
    TeamSettingsViewController *teamSettingsViewController = [[TeamSettingsViewController alloc] 
221c163ad5d9 continue working for team support on the ifrontend
koda
parents: 3250
diff changeset
    21
                                                              initWithStyle:UITableViewStyleGrouped];
3253
b0b1b1310b7e display team contents in the ifrontend
koda
parents: 3251
diff changeset
    22
    teamSettingsViewController.title = NSLocalizedString(@"Teams",@"");
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    23
    [array addObject:teamSettingsViewController];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    24
    [teamSettingsViewController release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    25
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    26
    self.controllers = array;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    27
    [array release];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    28
        
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    29
    [super viewDidLoad];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    30
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    31
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    32
- (void)didReceiveMemoryWarning {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    33
    // Releases the view if it doesn't have a superview.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    34
    [super didReceiveMemoryWarning];
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    35
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    36
    // Release any cached data, images, etc that aren't in use.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    37
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    38
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    39
- (void)viewDidUnload {
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    40
    self.controllers = nil;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    41
    self.popoverController = nil;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    42
    self.detailItem = nil;
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    43
    [super viewDidUnload];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    44
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    45
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    46
- (void)dealloc {
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    47
    [controllers release];
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    48
    [popoverController release];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    49
    [detailItem release];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    50
    [super dealloc];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    51
}
3165
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    52
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    53
#pragma mark -
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    54
#pragma mark Table view data source
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    55
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    56
    return 1;
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    57
}
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    58
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    59
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    60
    return [controllers count];
3165
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    61
}
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    62
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    63
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    64
    static NSString *CellIdentifier = @"Cell";
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    65
    
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    66
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    67
    if (cell == nil) {
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    68
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    69
                                       reuseIdentifier:CellIdentifier] autorelease];
3165
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    70
    }
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    71
    
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    72
    NSInteger row = [indexPath row];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    73
    UITableViewController *controller = [controllers objectAtIndex:row];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    74
    
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    75
    cell.textLabel.text = controller.title;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    76
    cell.imageView.image = [UIImage imageNamed:@"Icon.png"];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    77
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    78
    
3165
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    79
    return cell;
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    80
}
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    81
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    82
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    83
    NSInteger row = [indexPath row];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    84
    UITableViewController *nextController = [self.controllers objectAtIndex:row];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    85
    [self.navigationController pushViewController:nextController animated:YES];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    86
}
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    87
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    88
#pragma mark -
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    89
#pragma mark Managing the popover controller
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    90
// When setting the detail item, update the view and dismiss the popover controller if it's showing.
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    91
-(void) setDetailItem:(id) newDetailItem {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    92
    if (detailItem != newDetailItem) {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    93
        [detailItem release];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    94
        detailItem = [newDetailItem retain];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    95
        
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    96
        // Update the view.
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    97
       // navigationBar.topItem.title = (NSString*) detailItem;
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    98
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    99
		//test.text=(NSString*) detailItem;
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   100
    }
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   101
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   102
    if (popoverController != nil) {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   103
        [popoverController dismissPopoverAnimated:YES];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   104
    }        
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   105
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   106
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   107
#pragma mark -
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   108
#pragma mark Split view support
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   109
-(void) splitViewController:(UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   110
    barButtonItem.title = @"Master List";
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
   111
  //  [navigationBar.topItem setLeftBarButtonItem:barButtonItem animated:YES];
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   112
    self.popoverController = pc;
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   113
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   114
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   115
// Called when the view is shown again in the split view, invalidating the button and popover controller.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   116
-(void) splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
   117
  //  [navigationBar.topItem setLeftBarButtonItem:nil animated:YES];
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   118
    self.popoverController = nil;
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   119
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   120
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   121
#pragma mark -
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   122
#pragma mark Rotation support
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   123
// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   124
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   125
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   126
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   127
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   128
@end