21 |
21 |
22 |
22 |
23 @implementation AboutViewController |
23 @implementation AboutViewController |
24 @synthesize tableView, segmentedControl, people; |
24 @synthesize tableView, segmentedControl, people; |
25 |
25 |
26 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
26 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
27 return rotationManager(interfaceOrientation); |
27 return rotationManager(interfaceOrientation); |
28 } |
28 } |
29 |
29 |
30 -(void) viewDidLoad |
30 - (void)viewDidLoad |
31 { |
31 { |
32 [super viewDidLoad]; |
32 [super viewDidLoad]; |
33 |
33 |
34 [self.tableView setBackgroundColorForAnyTable:[UIColor clearColor]]; |
34 [self.tableView setBackgroundColorForAnyTable:[UIColor clearColor]]; |
35 self.tableView.allowsSelection = NO; |
35 self.tableView.allowsSelection = NO; |
36 |
36 |
37 NSArray *array = [[NSArray alloc] initWithContentsOfFile:CREDITS_FILE()]; |
37 NSArray *array = [[NSArray alloc] initWithContentsOfFile:CREDITS_FILE()]; |
38 self.people = array; |
38 self.people = array; |
39 [array release]; |
|
40 |
39 |
41 NSString *imgName; |
40 NSString *imgName; |
42 if (IS_IPAD()) |
41 if (IS_IPAD()) |
43 imgName = @"smallerBackground~ipad.png"; |
42 imgName = @"smallerBackground~ipad.png"; |
44 else |
43 else |
45 imgName = @"smallerBackground~iphone.png"; |
44 imgName = @"smallerBackground~iphone.png"; |
46 UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgName]; |
45 UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgName]; |
47 UIImageView *background = [[UIImageView alloc] initWithImage:img]; |
46 UIImageView *background = [[UIImageView alloc] initWithImage:img]; |
48 [img release]; |
|
49 background.frame = self.view.frame; |
47 background.frame = self.view.frame; |
50 background.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
48 background.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
51 [self.view insertSubview:background atIndex:0]; |
49 [self.view insertSubview:background atIndex:0]; |
52 [background release]; |
|
53 |
50 |
54 [self localizeSegmentedControl]; |
51 [self localizeSegmentedControl]; |
55 } |
52 } |
56 |
53 |
57 -(IBAction) buttonPressed:(id) sender { |
54 - (IBAction)buttonPressed:(id)sender { |
58 [[AudioManagerController mainManager] playBackSound]; |
55 [[AudioManagerController mainManager] playBackSound]; |
59 [self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; |
56 [self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; |
60 } |
57 } |
61 |
58 |
62 #pragma mark - Segmented Control |
59 #pragma mark - Segmented Control |
68 NSString *oldTitle = [self.segmentedControl titleForSegmentAtIndex:i]; |
65 NSString *oldTitle = [self.segmentedControl titleForSegmentAtIndex:i]; |
69 [self.segmentedControl setTitle:NSLocalizedStringFromTable(oldTitle, @"About", nil) forSegmentAtIndex:i]; |
66 [self.segmentedControl setTitle:NSLocalizedStringFromTable(oldTitle, @"About", nil) forSegmentAtIndex:i]; |
70 } |
67 } |
71 } |
68 } |
72 |
69 |
73 -(IBAction) segmentedControlChanged:(id) sender { |
70 - (IBAction)segmentedControlChanged:(id)sender { |
74 [[AudioManagerController mainManager] playClickSound]; |
71 [[AudioManagerController mainManager] playClickSound]; |
75 [self.tableView setContentOffset:CGPointMake(0, 0) animated:NO]; |
72 [self.tableView setContentOffset:CGPointMake(0, 0) animated:NO]; |
76 [self.tableView reloadData]; |
73 [self.tableView reloadData]; |
77 } |
74 } |
78 |
75 |
89 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
86 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
90 static NSString *CellIdentifier = @"Cell"; |
87 static NSString *CellIdentifier = @"Cell"; |
91 |
88 |
92 UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
89 UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
93 if (cell == nil) |
90 if (cell == nil) |
94 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; |
91 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; |
95 |
92 |
96 // first all the names, then the title (which is offset 5) |
93 // first all the names, then the title (which is offset 5) |
97 cell.textLabel.text = [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] objectAtIndex:[indexPath row]]; |
94 cell.textLabel.text = [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] objectAtIndex:[indexPath row]]; |
98 cell.textLabel.adjustsFontSizeToFitWidth = YES; |
95 cell.textLabel.adjustsFontSizeToFitWidth = YES; |
99 cell.textLabel.minimumFontSize = 8; |
96 cell.textLabel.minimumFontSize = 8; |
103 return cell; |
100 return cell; |
104 } |
101 } |
105 |
102 |
106 #pragma mark - |
103 #pragma mark - |
107 #pragma mark Table view delegate |
104 #pragma mark Table view delegate |
108 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
105 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
109 // do nothing |
106 // do nothing |
110 } |
107 } |
111 |
108 |
112 -(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { |
109 -(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { |
113 return 95; |
110 return 95; |
114 } |
111 } |
115 |
112 |
116 -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section { |
113 -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { |
117 NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; |
114 NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; |
118 char *fullver; |
115 char *fullver; |
119 int proto; |
116 int proto; |
120 HW_versionInfo(&proto, &fullver); |
117 HW_versionInfo(&proto, &fullver); |
121 |
118 |
131 label.textAlignment = NSTextAlignmentCenter; |
128 label.textAlignment = NSTextAlignmentCenter; |
132 label.font = [UIFont systemFontOfSize:16]; |
129 label.font = [UIFont systemFontOfSize:16]; |
133 label.textColor = [UIColor lightGrayColor]; |
130 label.textColor = [UIColor lightGrayColor]; |
134 label.numberOfLines = 5; |
131 label.numberOfLines = 5; |
135 label.text = footerString; |
132 label.text = footerString; |
136 [footerString release]; |
|
137 |
133 |
138 label.backgroundColor = [UIColor clearColor]; |
134 label.backgroundColor = [UIColor clearColor]; |
139 [footer addSubview:label]; |
135 [footer addSubview:label]; |
140 [label release]; |
136 return footer; |
141 return [footer autorelease]; |
|
142 } |
137 } |
143 |
138 |
144 #pragma mark - |
139 #pragma mark - |
145 #pragma mark Memory Management |
140 #pragma mark Memory Management |
146 -(void) didReceiveMemoryWarning { |
141 |
|
142 - (void)didReceiveMemoryWarning { |
147 self.people = nil; |
143 self.people = nil; |
148 [super didReceiveMemoryWarning]; |
144 [super didReceiveMemoryWarning]; |
149 } |
145 } |
150 |
146 |
151 -(void) viewDidUnload { |
|
152 self.tableView = nil; |
|
153 self.segmentedControl = nil; |
|
154 self.people = nil; |
|
155 [super viewDidUnload]; |
|
156 } |
|
157 |
|
158 -(void) dealloc { |
|
159 releaseAndNil(tableView); |
|
160 releaseAndNil(segmentedControl); |
|
161 releaseAndNil(people); |
|
162 [super dealloc]; |
|
163 } |
|
164 |
|
165 @end |
147 @end |