cocoaTouch/iPad/MasterViewController.m
changeset 3113 2829ea0dd47c
child 3165 3ec07a7d8456
equal deleted inserted replaced
3112:f1bbe35ddb83 3113:2829ea0dd47c
       
     1 //
       
     2 //  MasterViewController.m
       
     3 //  HedgewarsMobile
       
     4 //
       
     5 //  Created by Vittorio on 27/03/10.
       
     6 //  Copyright 2010 __MyCompanyName__. All rights reserved.
       
     7 //
       
     8 
       
     9 #import "MasterViewController.h"
       
    10 #import "DetailViewController.h"
       
    11 
       
    12 @implementation MasterViewController
       
    13 @synthesize detailViewController, optionList;
       
    14 
       
    15 #pragma mark -
       
    16 #pragma mark View lifecycle
       
    17 
       
    18 
       
    19 - (void)viewDidLoad {
       
    20     [super viewDidLoad];
       
    21     optionList = [[NSArray alloc] initWithObjects:NSLocalizedString(@"General",@""),
       
    22                                                   NSLocalizedString(@"Teams",@""),
       
    23                                                   NSLocalizedString(@"Weapons",@""),
       
    24                                                   NSLocalizedString(@"Schemes",@""),
       
    25                                                   nil];
       
    26     
       
    27     // Uncomment the following line to preserve selection between presentations.
       
    28     //self.clearsSelectionOnViewWillAppear = NO;
       
    29     // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
       
    30     //self.navigationItem.rightBarButtonItem = self.editButtonItem;
       
    31 }
       
    32 
       
    33 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
       
    34     return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
       
    35 }
       
    36 
       
    37 
       
    38 #pragma mark -
       
    39 #pragma mark Table view data source
       
    40 
       
    41 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
       
    42     return 1;
       
    43 }
       
    44 
       
    45 
       
    46 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
       
    47     return [optionList count];
       
    48 }
       
    49 
       
    50 
       
    51 // Customize the appearance of table view cells.
       
    52 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
       
    53     
       
    54     static NSString *CellIdentifier = @"Cell";
       
    55     
       
    56     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
       
    57     if (cell == nil) {
       
    58         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
       
    59         cell.textLabel.text = [optionList objectAtIndex:[indexPath row]];
       
    60     }
       
    61     
       
    62     return cell;
       
    63 }
       
    64 
       
    65 /*
       
    66 // Override to support editing the table view.
       
    67 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
       
    68     
       
    69     if (editingStyle == UITableViewCellEditingStyleDelete) {
       
    70         // Delete the row from the data source
       
    71         [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
       
    72     }   
       
    73     else if (editingStyle == UITableViewCellEditingStyleInsert) {
       
    74         // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
       
    75     }   
       
    76 }
       
    77 */
       
    78 
       
    79 /*
       
    80 // Override to support rearranging the table view.
       
    81 - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
       
    82 }
       
    83 */
       
    84 
       
    85 /*
       
    86 // Override to support conditional rearranging of the table view.
       
    87 - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
       
    88     // Return NO if you do not want the item to be re-orderable.
       
    89     return YES;
       
    90 }
       
    91 */
       
    92 
       
    93 #pragma mark -
       
    94 #pragma mark Table view delegate
       
    95 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
       
    96     // Navigation logic may go here. Create and push another view controller.
       
    97 	/*
       
    98 	 <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
       
    99      // ...
       
   100      // Pass the selected object to the new view controller.
       
   101 	 [self.navigationController pushViewController:detailViewController animated:YES];
       
   102 	 [detailViewController release];
       
   103 	 */
       
   104     detailViewController.detailItem = [[NSString alloc] initWithFormat:@"%d", [indexPath row]];
       
   105 }
       
   106 
       
   107 
       
   108 #pragma mark -
       
   109 #pragma mark Memory management
       
   110 -(void) didReceiveMemoryWarning {
       
   111     // Releases the view if it doesn't have a superview.
       
   112     [super didReceiveMemoryWarning];
       
   113     
       
   114     // Relinquish ownership any cached data, images, etc that aren't in use.
       
   115 }
       
   116 
       
   117 - (void)dealloc {
       
   118     [optionList release];
       
   119     [detailViewController release];
       
   120     [super dealloc];
       
   121 }
       
   122 
       
   123 
       
   124 @end
       
   125