3305
|
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 |
#import "TeamSettingsViewController.h"
|
|
11 |
#import "SDL_uikitappdelegate.h"
|
|
12 |
|
|
13 |
@implementation DetailViewController
|
|
14 |
@synthesize popoverController, controllers;
|
|
15 |
|
|
16 |
|
|
17 |
- (void)viewDidLoad {
|
|
18 |
self.title = NSLocalizedString(@"Settings",@"");
|
|
19 |
|
|
20 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
|
|
21 |
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:0 target:self action:@selector(dismissSplitView)];
|
|
22 |
|
|
23 |
NSMutableArray *array= [[NSMutableArray alloc] init];
|
|
24 |
|
|
25 |
TeamSettingsViewController *teamSettingsViewController = [[TeamSettingsViewController alloc]
|
|
26 |
initWithStyle:UITableViewStyleGrouped];
|
|
27 |
teamSettingsViewController.title = NSLocalizedString(@"Teams",@"");
|
3308
|
28 |
|
3305
|
29 |
[array addObject:teamSettingsViewController];
|
|
30 |
[teamSettingsViewController release];
|
|
31 |
|
|
32 |
self.controllers = array;
|
|
33 |
[array release];
|
|
34 |
|
|
35 |
[super viewDidLoad];
|
|
36 |
}
|
|
37 |
|
|
38 |
- (void)didReceiveMemoryWarning {
|
|
39 |
// Releases the view if it doesn't have a superview.
|
|
40 |
[super didReceiveMemoryWarning];
|
|
41 |
|
|
42 |
// Release any cached data, images, etc that aren't in use.
|
|
43 |
}
|
|
44 |
|
|
45 |
- (void)viewDidUnload {
|
|
46 |
self.controllers = nil;
|
|
47 |
self.popoverController = nil;
|
|
48 |
[super viewDidUnload];
|
|
49 |
}
|
|
50 |
|
|
51 |
- (void)dealloc {
|
|
52 |
[controllers release];
|
|
53 |
[popoverController release];
|
|
54 |
[super dealloc];
|
|
55 |
}
|
|
56 |
|
|
57 |
#pragma mark -
|
|
58 |
#pragma mark Table view data source
|
|
59 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
|
|
60 |
return 1;
|
|
61 |
}
|
|
62 |
|
|
63 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
64 |
return [controllers count];
|
|
65 |
}
|
|
66 |
|
|
67 |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
68 |
static NSString *CellIdentifier = @"Cell";
|
|
69 |
|
|
70 |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
|
|
71 |
if (cell == nil) {
|
|
72 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
|
|
73 |
reuseIdentifier:CellIdentifier] autorelease];
|
|
74 |
}
|
|
75 |
|
|
76 |
NSInteger row = [indexPath row];
|
|
77 |
UITableViewController *controller = [controllers objectAtIndex:row];
|
|
78 |
|
|
79 |
cell.textLabel.text = controller.title;
|
|
80 |
cell.imageView.image = [UIImage imageNamed:@"Icon.png"];
|
|
81 |
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
|
82 |
|
|
83 |
return cell;
|
|
84 |
}
|
|
85 |
|
|
86 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
87 |
NSInteger row = [indexPath row];
|
|
88 |
UITableViewController *nextController = [self.controllers objectAtIndex:row];
|
|
89 |
[self.navigationController pushViewController:nextController animated:YES];
|
|
90 |
}
|
|
91 |
|
|
92 |
/*
|
|
93 |
#pragma mark -
|
|
94 |
#pragma mark Managing the popover controller
|
|
95 |
// When setting the detail item, update the view and dismiss the popover controller if it's showing.
|
|
96 |
-(void) setDetailItem:(id) newDetailItem {
|
|
97 |
if (detailItem != newDetailItem) {
|
|
98 |
[detailItem release];
|
|
99 |
detailItem = [newDetailItem retain];
|
|
100 |
|
|
101 |
// Update the view.
|
|
102 |
// navigationBar.topItem.title = (NSString*) detailItem;
|
|
103 |
|
|
104 |
//test.text=(NSString*) detailItem;
|
|
105 |
}
|
|
106 |
|
|
107 |
// if (popoverController != nil) {
|
|
108 |
// [popoverController dismissPopoverAnimated:YES];
|
|
109 |
// }
|
|
110 |
}
|
|
111 |
*/
|
|
112 |
|
|
113 |
#pragma mark -
|
|
114 |
#pragma mark Split view support
|
|
115 |
#ifdef __IPHONE_3_2
|
|
116 |
-(void) splitViewController:(UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {
|
|
117 |
barButtonItem.title = @"Master List";
|
|
118 |
// [navigationBar.topItem setLeftBarButtonItem:barButtonItem animated:YES];
|
|
119 |
self.popoverController = pc;
|
|
120 |
}
|
|
121 |
|
|
122 |
// Called when the view is shown again in the split view, invalidating the button and popover controller.
|
|
123 |
-(void) splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
|
|
124 |
// [navigationBar.topItem setLeftBarButtonItem:nil animated:YES];
|
|
125 |
self.popoverController = nil;
|
|
126 |
}
|
|
127 |
#endif
|
|
128 |
#pragma mark -
|
|
129 |
#pragma mark Rotation support
|
|
130 |
// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
|
|
131 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
|
132 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
|
|
133 |
}
|
|
134 |
|
|
135 |
-(IBAction) dismissSplitView {
|
|
136 |
[[NSNotificationCenter defaultCenter] postNotificationName:@"dismissModalView" object:nil];
|
|
137 |
}
|
|
138 |
|
|
139 |
@end
|