author | palewolf |
Fri, 02 Apr 2010 08:46:57 +0000 | |
changeset 3248 | 8d4c61f6f30c |
parent 3165 | 3ec07a7d8456 |
child 3250 | d5cd1a617123 |
permissions | -rw-r--r-- |
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 |
|
3165
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
13 |
@synthesize navigationBar, popoverController, detailItem, test, optionList,table; |
3113 | 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]; |
|
3165
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
29 |
optionList = [[NSArray alloc] initWithObjects:NSLocalizedString(@"General",@""), |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
30 |
NSLocalizedString(@"Teams",@""), |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
31 |
NSLocalizedString(@"Weapons",@""), |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
32 |
NSLocalizedString(@"Schemes",@""), |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
33 |
nil]; |
3113 | 34 |
} |
35 |
||
36 |
||
37 |
- (void)didReceiveMemoryWarning { |
|
38 |
// Releases the view if it doesn't have a superview. |
|
39 |
[super didReceiveMemoryWarning]; |
|
40 |
||
41 |
// Release any cached data, images, etc that aren't in use. |
|
42 |
} |
|
43 |
||
44 |
||
45 |
- (void)viewDidUnload { |
|
46 |
[super viewDidUnload]; |
|
47 |
// Release any retained subviews of the main view. |
|
48 |
// e.g. self.myOutlet = nil; |
|
49 |
} |
|
50 |
||
51 |
||
52 |
- (void)dealloc { |
|
3165
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
53 |
[optionList release]; |
3113 | 54 |
[navigationBar release]; |
55 |
[popoverController release]; |
|
56 |
[detailItem release]; |
|
57 |
[super dealloc]; |
|
58 |
} |
|
3165
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
59 |
|
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
60 |
#pragma mark - |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
61 |
#pragma mark Table view data source |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
62 |
|
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
63 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
64 |
return 1; |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
65 |
} |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
66 |
|
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
67 |
|
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
68 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
69 |
return [optionList count]; |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
70 |
} |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
71 |
|
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
72 |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
73 |
static NSString *CellIdentifier = @"Cell"; |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
74 |
|
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
75 |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
76 |
if (cell == nil) { |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
77 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
78 |
cell.textLabel.text = [optionList objectAtIndex:[indexPath row]]; |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
79 |
} |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
80 |
|
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
81 |
return cell; |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
82 |
} |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
83 |
|
3113 | 84 |
#pragma mark - |
85 |
#pragma mark Managing the popover controller |
|
86 |
||
87 |
/* |
|
88 |
When setting the detail item, update the view and dismiss the popover controller if it's showing. |
|
89 |
*/ |
|
90 |
-(void) setDetailItem:(id) newDetailItem { |
|
91 |
if (detailItem != newDetailItem) { |
|
92 |
[detailItem release]; |
|
93 |
detailItem = [newDetailItem retain]; |
|
94 |
||
95 |
// Update the view. |
|
96 |
navigationBar.topItem.title = (NSString*) detailItem; |
|
97 |
||
98 |
test.text=(NSString*) detailItem; |
|
99 |
} |
|
100 |
||
101 |
if (popoverController != nil) { |
|
102 |
[popoverController dismissPopoverAnimated:YES]; |
|
103 |
} |
|
104 |
} |
|
105 |
||
106 |
||
107 |
#pragma mark - |
|
108 |
#pragma mark Split view support |
|
109 |
||
110 |
-(void) splitViewController:(UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc { |
|
111 |
barButtonItem.title = @"Master List"; |
|
112 |
[navigationBar.topItem setLeftBarButtonItem:barButtonItem animated:YES]; |
|
113 |
self.popoverController = pc; |
|
114 |
} |
|
115 |
||
116 |
||
117 |
// Called when the view is shown again in the split view, invalidating the button and popover controller. |
|
118 |
-(void) splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem { |
|
119 |
[navigationBar.topItem setLeftBarButtonItem:nil animated:YES]; |
|
120 |
self.popoverController = nil; |
|
121 |
} |
|
122 |
||
123 |
#pragma mark - |
|
124 |
#pragma mark Rotation support |
|
125 |
||
126 |
// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape. |
|
127 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
|
128 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); |
|
129 |
} |
|
130 |
||
131 |
-(IBAction) dismissSplitView { |
|
132 |
[[NSNotificationCenter defaultCenter] postNotificationName:@"dismissModalView" object:nil]; |
|
133 |
} |
|
134 |
||
135 |
@end |