cocoaTouch/DetailViewController.m
changeset 3316 52f0482b043f
parent 3312 6d8f1c76756d
child 3335 2520ee7a5484
equal deleted inserted replaced
3315:4e2813713358 3316:52f0482b043f
    15 @synthesize popoverController, controllers;
    15 @synthesize popoverController, controllers;
    16 
    16 
    17 
    17 
    18 - (void)viewDidLoad {
    18 - (void)viewDidLoad {
    19     self.title = NSLocalizedString(@"Settings",@"");
    19     self.title = NSLocalizedString(@"Settings",@"");
    20     
       
    21     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
       
    22         self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:0 target:self action:@selector(dismissSplitView)];
       
    23 
    20 
       
    21     // allocate controllers and store them into the array
    24     NSMutableArray *array= [[NSMutableArray alloc] init];
    22     NSMutableArray *array= [[NSMutableArray alloc] init];
    25 
    23 
    26     GeneralSettingsViewController *generalSettingsViewController = [[GeneralSettingsViewController alloc]
    24     GeneralSettingsViewController *generalSettingsViewController = [[GeneralSettingsViewController alloc]
    27                                                                     initWithStyle:UITableViewStyleGrouped];
    25                                                                     initWithStyle:UITableViewStyleGrouped];
    28     generalSettingsViewController.title = NSLocalizedString(@"General",@"");
    26     generalSettingsViewController.title = NSLocalizedString(@"General",@"");
    35     [array addObject:teamSettingsViewController];
    33     [array addObject:teamSettingsViewController];
    36     [teamSettingsViewController release];
    34     [teamSettingsViewController release];
    37     
    35     
    38     self.controllers = array;
    36     self.controllers = array;
    39     [array release];
    37     [array release];
    40         
    38     
       
    39     // on ipad make the general setting the first view, on iphone add the "Done" button on top left
       
    40     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
       
    41         UITableViewController *nextController = [self.controllers objectAtIndex:0];
       
    42         nextController.navigationItem.hidesBackButton = YES;
       
    43         [self.navigationController pushViewController:nextController animated:NO];
       
    44     } else {
       
    45         self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:0 target:self action:@selector(dismissSplitView)];
       
    46     }
       
    47 
    41     [super viewDidLoad];
    48     [super viewDidLoad];
    42 }
    49 }
    43 
    50 
    44 - (void)didReceiveMemoryWarning {
    51 - (void)didReceiveMemoryWarning {
    45     // Releases the view if it doesn't have a superview.
    52     // Releases the view if it doesn't have a superview.
    46     [super didReceiveMemoryWarning];
    53     [super didReceiveMemoryWarning];
    47 
       
    48     // Release any cached data, images, etc that aren't in use.
    54     // Release any cached data, images, etc that aren't in use.
    49 }
    55 }
    50 
    56 
    51 - (void)viewDidUnload {
    57 - (void)viewDidUnload {
    52     self.controllers = nil;
    58     self.controllers = nil;
   129 -(void) splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
   135 -(void) splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
   130   //  [navigationBar.topItem setLeftBarButtonItem:nil animated:YES];
   136   //  [navigationBar.topItem setLeftBarButtonItem:nil animated:YES];
   131     self.popoverController = nil;
   137     self.popoverController = nil;
   132 }
   138 }
   133 #endif
   139 #endif
       
   140 
   134 #pragma mark -
   141 #pragma mark -
   135 #pragma mark Rotation support
   142 #pragma mark Rotation support
   136 // Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
   143 // Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
   137 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
   144 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
   138     return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
   145     return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);