cocoaTouch/iPad/DetailViewController.m
changeset 3250 d5cd1a617123
parent 3165 3ec07a7d8456
child 3251 221c163ad5d9
--- a/cocoaTouch/iPad/DetailViewController.m	Fri Apr 02 10:50:10 2010 +0000
+++ b/cocoaTouch/iPad/DetailViewController.m	Fri Apr 02 12:38:36 2010 +0000
@@ -7,51 +7,44 @@
 //
 
 #import "DetailViewController.h"
-
+#import "TeamSettingsViewController.h"
 
 @implementation DetailViewController
-@synthesize navigationBar, popoverController, detailItem, test, optionList,table;
-
-/*
- // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
-    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
-        // Custom initialization
-    }
-    return self;
-}
-*/
+@synthesize popoverController, detailItem, controllers;
 
 
 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
 - (void)viewDidLoad {
+    self.title =@"First";
+    NSMutableArray *array= [[NSMutableArray alloc] init];
+
+    TeamSettingsViewController *teamSettingsViewController = [[TeamSettingsViewController alloc] initWithStyle:UITableViewStylePlain];
+    teamSettingsViewController.title =NSLocalizedString(@"Teams",@"");
+    [array addObject:teamSettingsViewController];
+    [teamSettingsViewController release];
+    
+    self.controllers = array;
+    [array release];
+        
     [super viewDidLoad];
-        optionList = [[NSArray alloc] initWithObjects:NSLocalizedString(@"General",@""),
-                                                  NSLocalizedString(@"Teams",@""),
-                                                  NSLocalizedString(@"Weapons",@""),
-                                                  NSLocalizedString(@"Schemes",@""),
-                                                  nil];
 }
 
-
 - (void)didReceiveMemoryWarning {
     // Releases the view if it doesn't have a superview.
     [super didReceiveMemoryWarning];
-    
+
     // Release any cached data, images, etc that aren't in use.
 }
 
-
 - (void)viewDidUnload {
+    self.controllers = nil;
+    self.popoverController = nil;
+    self.detailItem = nil;
     [super viewDidUnload];
-    // Release any retained subviews of the main view.
-    // e.g. self.myOutlet = nil;
 }
 
-
 - (void)dealloc {
-    [optionList release];
-    [navigationBar release];
+    [controllers release];
     [popoverController release];
     [detailItem release];
     [super dealloc];
@@ -59,14 +52,12 @@
 
 #pragma mark -
 #pragma mark Table view data source
-
 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
     return 1;
 }
 
-
 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-    return [optionList count];
+    return [controllers count];
 }
 
 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
@@ -74,28 +65,38 @@
     
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
     if (cell == nil) {
-        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
-        cell.textLabel.text = [optionList objectAtIndex:[indexPath row]];
+        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
+                                       reuseIdentifier:CellIdentifier] autorelease];
     }
     
+    NSInteger row = [indexPath row];
+    UITableViewController *controller = [controllers objectAtIndex:row];
+    
+    cell.textLabel.text = controller.title;
+    cell.imageView.image = [UIImage imageNamed:@"Icon.png"];
+    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
+    
     return cell;
 }
 
+-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+    NSInteger row = [indexPath row];
+    UITableViewController *nextController = [self.controllers objectAtIndex:row];
+    [self.navigationController pushViewController:nextController animated:YES];
+}
+
 #pragma mark -
 #pragma mark Managing the popover controller
-
-/*
- When setting the detail item, update the view and dismiss the popover controller if it's showing.
- */
+// When setting the detail item, update the view and dismiss the popover controller if it's showing.
 -(void) setDetailItem:(id) newDetailItem {
     if (detailItem != newDetailItem) {
         [detailItem release];
         detailItem = [newDetailItem retain];
         
         // Update the view.
-        navigationBar.topItem.title = (NSString*) detailItem;
+       // navigationBar.topItem.title = (NSString*) detailItem;
 
-		test.text=(NSString*) detailItem;
+		//test.text=(NSString*) detailItem;
     }
 
     if (popoverController != nil) {
@@ -103,33 +104,25 @@
     }        
 }
 
-
 #pragma mark -
 #pragma mark Split view support
-
 -(void) splitViewController:(UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {
     barButtonItem.title = @"Master List";
-    [navigationBar.topItem setLeftBarButtonItem:barButtonItem animated:YES];
+  //  [navigationBar.topItem setLeftBarButtonItem:barButtonItem animated:YES];
     self.popoverController = pc;
 }
 
-
 // Called when the view is shown again in the split view, invalidating the button and popover controller.
 -(void) splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
-    [navigationBar.topItem setLeftBarButtonItem:nil animated:YES];
+  //  [navigationBar.topItem setLeftBarButtonItem:nil animated:YES];
     self.popoverController = nil;
 }
 
 #pragma mark -
 #pragma mark Rotation support
-
 // Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
     return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
 }
 
--(IBAction) dismissSplitView {
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissModalView" object:nil];
-}
-
 @end