3113
|
1 |
//
|
|
2 |
// DetailViewController.m
|
|
3 |
// HedgewarsMobile
|
|
4 |
//
|
|
5 |
// Created by Vittorio on 27/03/10.
|
|
6 |
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
|
7 |
//
|
|
8 |
|
|
9 |
#import "DetailViewController.h"
|
|
10 |
|
|
11 |
|
|
12 |
@implementation DetailViewController
|
|
13 |
@synthesize navigationBar, popoverController, detailItem, test;
|
|
14 |
|
|
15 |
/*
|
|
16 |
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
|
|
17 |
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
|
18 |
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
|
|
19 |
// Custom initialization
|
|
20 |
}
|
|
21 |
return self;
|
|
22 |
}
|
|
23 |
*/
|
|
24 |
|
|
25 |
|
|
26 |
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
|
|
27 |
- (void)viewDidLoad {
|
|
28 |
[super viewDidLoad];
|
|
29 |
}
|
|
30 |
|
|
31 |
|
|
32 |
- (void)didReceiveMemoryWarning {
|
|
33 |
// Releases the view if it doesn't have a superview.
|
|
34 |
[super didReceiveMemoryWarning];
|
|
35 |
|
|
36 |
// Release any cached data, images, etc that aren't in use.
|
|
37 |
}
|
|
38 |
|
|
39 |
|
|
40 |
- (void)viewDidUnload {
|
|
41 |
[super viewDidUnload];
|
|
42 |
// Release any retained subviews of the main view.
|
|
43 |
// e.g. self.myOutlet = nil;
|
|
44 |
}
|
|
45 |
|
|
46 |
|
|
47 |
- (void)dealloc {
|
|
48 |
[navigationBar release];
|
|
49 |
[popoverController release];
|
|
50 |
[detailItem release];
|
|
51 |
[super dealloc];
|
|
52 |
}
|
|
53 |
#pragma mark -
|
|
54 |
#pragma mark Managing the popover controller
|
|
55 |
|
|
56 |
/*
|
|
57 |
When setting the detail item, update the view and dismiss the popover controller if it's showing.
|
|
58 |
*/
|
|
59 |
-(void) setDetailItem:(id) newDetailItem {
|
|
60 |
if (detailItem != newDetailItem) {
|
|
61 |
[detailItem release];
|
|
62 |
detailItem = [newDetailItem retain];
|
|
63 |
|
|
64 |
// Update the view.
|
|
65 |
navigationBar.topItem.title = (NSString*) detailItem;
|
|
66 |
|
|
67 |
test.text=(NSString*) detailItem;
|
|
68 |
}
|
|
69 |
|
|
70 |
if (popoverController != nil) {
|
|
71 |
[popoverController dismissPopoverAnimated:YES];
|
|
72 |
}
|
|
73 |
}
|
|
74 |
|
|
75 |
|
|
76 |
#pragma mark -
|
|
77 |
#pragma mark Split view support
|
|
78 |
|
|
79 |
-(void) splitViewController:(UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {
|
|
80 |
barButtonItem.title = @"Master List";
|
|
81 |
[navigationBar.topItem setLeftBarButtonItem:barButtonItem animated:YES];
|
|
82 |
self.popoverController = pc;
|
|
83 |
}
|
|
84 |
|
|
85 |
|
|
86 |
// Called when the view is shown again in the split view, invalidating the button and popover controller.
|
|
87 |
-(void) splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
|
|
88 |
[navigationBar.topItem setLeftBarButtonItem:nil animated:YES];
|
|
89 |
self.popoverController = nil;
|
|
90 |
}
|
|
91 |
|
|
92 |
#pragma mark -
|
|
93 |
#pragma mark Rotation support
|
|
94 |
|
|
95 |
// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
|
|
96 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
|
97 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
|
|
98 |
}
|
|
99 |
|
|
100 |
-(IBAction) dismissSplitView {
|
|
101 |
[[NSNotificationCenter defaultCenter] postNotificationName:@"dismissModalView" object:nil];
|
|
102 |
}
|
|
103 |
|
|
104 |
@end
|