equal
deleted
inserted
replaced
20 |
20 |
21 |
21 |
22 #import "VoicesViewController.h" |
22 #import "VoicesViewController.h" |
23 #import "CommodityFunctions.h" |
23 #import "CommodityFunctions.h" |
24 |
24 |
25 |
|
26 @implementation VoicesViewController |
25 @implementation VoicesViewController |
27 @synthesize teamDictionary, voiceArray, lastIndexPath; |
26 @synthesize teamDictionary, voiceArray, lastIndexPath; |
28 |
27 |
29 |
28 |
30 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
29 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
31 return rotationManager(interfaceOrientation); |
30 return rotationManager(interfaceOrientation); |
32 } |
31 } |
33 |
|
34 |
32 |
35 #pragma mark - |
33 #pragma mark - |
36 #pragma mark View lifecycle |
34 #pragma mark View lifecycle |
37 -(void) viewDidLoad { |
35 -(void) viewDidLoad { |
38 [super viewDidLoad]; |
36 [super viewDidLoad]; |
53 |
51 |
54 // this moves the tableview to the top |
52 // this moves the tableview to the top |
55 [self.tableView setContentOffset:CGPointMake(0,0) animated:NO]; |
53 [self.tableView setContentOffset:CGPointMake(0,0) animated:NO]; |
56 } |
54 } |
57 |
55 |
58 -(void) viewWillDisappear:(BOOL)animated { |
56 -(void) viewDidAppear:(BOOL)animated { |
59 [super viewWillDisappear:animated]; |
57 [super viewDidAppear:animated]; |
|
58 Mix_OpenAudio(44100, 0x8010, 1, 1024); |
|
59 } |
|
60 |
|
61 -(void) viewDidDisappear:(BOOL)animated { |
|
62 [super viewDidDisappear:animated]; |
60 if(voiceBeingPlayed != NULL) { |
63 if(voiceBeingPlayed != NULL) { |
61 Mix_HaltChannel(lastChannel); |
64 Mix_HaltChannel(lastChannel); |
62 Mix_FreeChunk(voiceBeingPlayed); |
65 Mix_FreeChunk(voiceBeingPlayed); |
63 voiceBeingPlayed = NULL; |
66 voiceBeingPlayed = NULL; |
64 } |
67 } |
|
68 Mix_CloseAudio(); |
65 } |
69 } |
66 |
70 |
67 |
71 |
68 #pragma mark - |
72 #pragma mark - |
69 #pragma mark Table view data source |
73 #pragma mark Table view data source |
115 self.lastIndexPath = indexPath; |
119 self.lastIndexPath = indexPath; |
116 [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; |
120 [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; |
117 } |
121 } |
118 [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; |
122 [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; |
119 |
123 |
|
124 // stop any sound before playing another one |
120 if (voiceBeingPlayed != NULL) { |
125 if (voiceBeingPlayed != NULL) { |
121 Mix_HaltChannel(lastChannel); |
126 Mix_HaltChannel(lastChannel); |
122 Mix_FreeChunk(voiceBeingPlayed); |
127 Mix_FreeChunk(voiceBeingPlayed); |
123 voiceBeingPlayed = NULL; |
128 voiceBeingPlayed = NULL; |
124 } |
129 } |
135 |
140 |
136 |
141 |
137 #pragma mark - |
142 #pragma mark - |
138 #pragma mark Memory management |
143 #pragma mark Memory management |
139 -(void) didReceiveMemoryWarning { |
144 -(void) didReceiveMemoryWarning { |
140 // Releases the view if it doesn't have a superview. |
145 if (voiceBeingPlayed != NULL) { |
|
146 Mix_HaltChannel(lastChannel); |
|
147 Mix_FreeChunk(voiceBeingPlayed); |
|
148 voiceBeingPlayed = NULL; |
|
149 } |
|
150 MSG_MEMCLEAN(); |
141 [super didReceiveMemoryWarning]; |
151 [super didReceiveMemoryWarning]; |
142 // Relinquish ownership any cached data, images, etc that aren't in use. |
|
143 } |
152 } |
144 |
153 |
145 -(void) viewDidUnload { |
154 -(void) viewDidUnload { |
146 voiceBeingPlayed = NULL; |
155 voiceBeingPlayed = NULL; |
147 self.lastIndexPath = nil; |
156 self.lastIndexPath = nil; |