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