cocoaTouch/iPad/DetailViewController.m
changeset 3113 2829ea0dd47c
child 3165 3ec07a7d8456
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cocoaTouch/iPad/DetailViewController.m	Sat Mar 27 16:57:18 2010 +0000
@@ -0,0 +1,104 @@
+    //
+//  DetailViewController.m
+//  HedgewarsMobile
+//
+//  Created by Vittorio on 27/03/10.
+//  Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import "DetailViewController.h"
+
+
+@implementation DetailViewController
+@synthesize navigationBar, popoverController, detailItem, test;
+
+/*
+ // 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;
+}
+*/
+
+
+// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
+- (void)viewDidLoad {
+    [super viewDidLoad];
+}
+
+
+- (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 {
+    [super viewDidUnload];
+    // Release any retained subviews of the main view.
+    // e.g. self.myOutlet = nil;
+}
+
+
+- (void)dealloc {
+    [navigationBar release];
+    [popoverController release];
+    [detailItem release];
+    [super dealloc];
+}
+#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.
+ */
+-(void) setDetailItem:(id) newDetailItem {
+    if (detailItem != newDetailItem) {
+        [detailItem release];
+        detailItem = [newDetailItem retain];
+        
+        // Update the view.
+        navigationBar.topItem.title = (NSString*) detailItem;
+
+		test.text=(NSString*) detailItem;
+    }
+
+    if (popoverController != nil) {
+        [popoverController dismissPopoverAnimated:YES];
+    }        
+}
+
+
+#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];
+    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];
+    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