author | koda |
Fri, 02 Apr 2010 15:08:43 +0000 | |
changeset 3251 | 221c163ad5d9 |
parent 3250 | d5cd1a617123 |
child 3253 | b0b1b1310b7e |
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" |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
10 |
#import "TeamSettingsViewController.h" |
3113 | 11 |
|
12 |
@implementation DetailViewController |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
13 |
@synthesize popoverController, detailItem, controllers; |
3113 | 14 |
|
15 |
||
16 |
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. |
|
17 |
- (void)viewDidLoad { |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
18 |
self.title =@"First"; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
19 |
NSMutableArray *array= [[NSMutableArray alloc] init]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
20 |
|
3251 | 21 |
TeamSettingsViewController *teamSettingsViewController = [[TeamSettingsViewController alloc] |
22 |
initWithStyle:UITableViewStyleGrouped]; |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
23 |
teamSettingsViewController.title =NSLocalizedString(@"Teams",@""); |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
24 |
[array addObject:teamSettingsViewController]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
25 |
[teamSettingsViewController release]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
26 |
|
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
27 |
self.controllers = array; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
28 |
[array release]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
29 |
|
3113 | 30 |
[super viewDidLoad]; |
31 |
} |
|
32 |
||
33 |
- (void)didReceiveMemoryWarning { |
|
34 |
// Releases the view if it doesn't have a superview. |
|
35 |
[super didReceiveMemoryWarning]; |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
36 |
|
3113 | 37 |
// Release any cached data, images, etc that aren't in use. |
38 |
} |
|
39 |
||
40 |
- (void)viewDidUnload { |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
41 |
self.controllers = nil; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
42 |
self.popoverController = nil; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
43 |
self.detailItem = nil; |
3113 | 44 |
[super viewDidUnload]; |
45 |
} |
|
46 |
||
47 |
- (void)dealloc { |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
48 |
[controllers release]; |
3113 | 49 |
[popoverController release]; |
50 |
[detailItem release]; |
|
51 |
[super dealloc]; |
|
52 |
} |
|
3165
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
53 |
|
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
54 |
#pragma mark - |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
55 |
#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
|
56 |
-(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
|
57 |
return 1; |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
58 |
} |
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 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
61 |
return [controllers count]; |
3165
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 |
|
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
64 |
-(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
|
65 |
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
|
66 |
|
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
67 |
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
|
68 |
if (cell == nil) { |
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
69 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
70 |
reuseIdentifier:CellIdentifier] autorelease]; |
3165
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 |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
73 |
NSInteger row = [indexPath row]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
74 |
UITableViewController *controller = [controllers objectAtIndex:row]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
75 |
|
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
76 |
cell.textLabel.text = controller.title; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
77 |
cell.imageView.image = [UIImage imageNamed:@"Icon.png"]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
78 |
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
79 |
|
3165
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
80 |
return cell; |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
81 |
} |
3ec07a7d8456
just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents:
3113
diff
changeset
|
82 |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
83 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
84 |
NSInteger row = [indexPath row]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
85 |
UITableViewController *nextController = [self.controllers objectAtIndex:row]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
86 |
[self.navigationController pushViewController:nextController animated:YES]; |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
87 |
} |
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
88 |
|
3113 | 89 |
#pragma mark - |
90 |
#pragma mark Managing the popover controller |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
91 |
// When setting the detail item, update the view and dismiss the popover controller if it's showing. |
3113 | 92 |
-(void) setDetailItem:(id) newDetailItem { |
93 |
if (detailItem != newDetailItem) { |
|
94 |
[detailItem release]; |
|
95 |
detailItem = [newDetailItem retain]; |
|
96 |
||
97 |
// Update the view. |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
98 |
// navigationBar.topItem.title = (NSString*) detailItem; |
3113 | 99 |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
100 |
//test.text=(NSString*) detailItem; |
3113 | 101 |
} |
102 |
||
103 |
if (popoverController != nil) { |
|
104 |
[popoverController dismissPopoverAnimated:YES]; |
|
105 |
} |
|
106 |
} |
|
107 |
||
108 |
#pragma mark - |
|
109 |
#pragma mark Split view support |
|
110 |
-(void) splitViewController:(UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc { |
|
111 |
barButtonItem.title = @"Master List"; |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
112 |
// [navigationBar.topItem setLeftBarButtonItem:barButtonItem animated:YES]; |
3113 | 113 |
self.popoverController = pc; |
114 |
} |
|
115 |
||
116 |
// Called when the view is shown again in the split view, invalidating the button and popover controller. |
|
117 |
-(void) splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem { |
|
3250
d5cd1a617123
intial support for team configuration on the ifrontend
koda
parents:
3165
diff
changeset
|
118 |
// [navigationBar.topItem setLeftBarButtonItem:nil animated:YES]; |
3113 | 119 |
self.popoverController = nil; |
120 |
} |
|
121 |
||
122 |
#pragma mark - |
|
123 |
#pragma mark Rotation support |
|
124 |
// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape. |
|
125 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
|
126 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); |
|
127 |
} |
|
128 |
||
129 |
@end |