cocoaTouch/DetailViewController.m
changeset 3357 3836a31879e7
parent 3356 3ae3fccb439e
child 3364 e5403e2bf02c
equal deleted inserted replaced
3356:3ae3fccb439e 3357:3836a31879e7
    20 
    20 
    21 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    21 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    22 	return rotationManager(interfaceOrientation);
    22 	return rotationManager(interfaceOrientation);
    23 }
    23 }
    24 
    24 
    25 - (void)viewDidLoad {
    25 -(void) viewDidLoad {
    26     self.title = NSLocalizedString(@"Settings",@"");
    26     self.title = NSLocalizedString(@"Settings",@"");
    27 
    27 
    28     // allocate controllers and store them into the array
    28     // allocate controllers and store them into the array
    29     NSArray *array= [[NSArray alloc] initWithObjects:NSLocalizedString(@"General",@""), 
    29     NSArray *array= [[NSArray alloc] initWithObjects:NSLocalizedString(@"General",@""), 
    30                                                      NSLocalizedString(@"Teams",@""),
    30                                                      NSLocalizedString(@"Teams",@""),
    35     [array release];
    35     [array release];
    36     
    36     
    37     // on ipad make the general setting the first view, on iphone add the "Done" button on top left
    37     // on ipad make the general setting the first view, on iphone add the "Done" button on top left
    38     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    38     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    39         
    39         
    40         // show some stuff
    40         UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(112, 112, 480, 320)];
       
    41         label.text = @"Press the buttons on the left";
       
    42         label.font = [UIFont systemFontOfSize:20];
       
    43         label.textAlignment = UITextAlignmentCenter;
       
    44         [self.view addSubview:label];
       
    45         [label release];
       
    46         
    41         
    47         
    42         //[self.navigationController pushViewController:nextController animated:NO];
    48         //[self.navigationController pushViewController:nextController animated:NO];
    43     } else {
    49     } else {
    44         self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
    50         self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
    45                                                                                               target:self
    51                                                                                               target:self
    51 
    57 
    52 
    58 
    53 #pragma mark -
    59 #pragma mark -
    54 #pragma mark Table view data source
    60 #pragma mark Table view data source
    55 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
    61 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
    56     return 1;
    62     // don't display 
       
    63     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
       
    64         return 0;
       
    65     else
       
    66         return 1;
    57 }
    67 }
    58 
    68 
    59 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    69 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    60     return [controllerNames count];
    70     return [controllerNames count];
    61 }
    71 }
    76     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    86     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    77     
    87     
    78     return cell;
    88     return cell;
    79 }
    89 }
    80 
    90 
       
    91 #pragma mark -
       
    92 #pragma mark Table view delegate
    81 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    93 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    82     NSInteger row = [indexPath row];
    94     NSInteger row = [indexPath row];
    83     UIViewController *nextController;
    95     UIViewController *nextController;
    84     
    96     
    85     switch (row) {
    97     switch (row) {