-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAVFViewControllerAddExperimento.m
250 lines (169 loc) · 6.99 KB
/
AVFViewControllerAddExperimento.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
//
// AVFViewControllerAddExperimento.m
// TREA
//
// Created by andre vinicius alves fonseca on 12/08/14.
// Copyright (c) 2014 Andre Ltda. All rights reserved.
//
#import "AVFViewControllerAddExperimento.h"
#import "AVFViewController+CWPopup.h"
#import "AVFViewController.h"
@interface AVFViewControllerAddExperimento ()
@end
@implementation AVFViewControllerAddExperimento
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.isSave = NO;
self.tableListaProgramas.delegate = self;
_selectedIndexes = [[NSMutableArray alloc]init];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)addPrograma:(id)sender {
AVFViewController *addPrograma = [[AVFViewController alloc]init];
[self presentViewController:addPrograma animated:YES completion:nil];
}
- (IBAction)salvarExperimento:(id)sender {
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.view endEditing:YES];
}
//
// metodos da tableView
//
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
self.nomeProgramas = [[NSMutableArray alloc]initWithContentsOfFile:[self caminhoPerfil]];
return self.nomeProgramas.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
self.nomeProgramas = [[NSMutableArray alloc]initWithContentsOfFile:[self caminhoPerfil]];
static NSString *identificador = @"celula";
UITableViewCell *thisCell = [tableView dequeueReusableCellWithIdentifier:identificador];
if (thisCell == nil) {
thisCell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identificador];
}
thisCell.textLabel.text = [self.nomeProgramas objectAtIndex:indexPath.row];
return thisCell;
}
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
if ([selectedCell accessoryType] == UITableViewCellAccessoryNone) {
[selectedCell setAccessoryType:UITableViewCellAccessoryCheckmark];
[_selectedIndexes addObject:[NSNumber numberWithInt:indexPath.row]];
} else {
[selectedCell setAccessoryType:UITableViewCellAccessoryNone];
[_selectedIndexes removeObject:[NSNumber numberWithInt:indexPath.row]];
}
[tableView deselectRowAtIndexPath:indexPath animated:NO];
NSLog(@"%@", _selectedIndexes);
}
-(void)viewDidAppear:(BOOL)animated
{
[self.tableListaProgramas reloadData];
}
-(void)viewWillAppear:(BOOL)animated{
// self.programa = [[Programa alloc]init];
//pegando da plist
self.nomeProgramas = [[NSMutableArray alloc]initWithContentsOfFile:[self caminhoPerfil]];
// self.programa.nomePrograma = [[Programa sharePrograma] obterSharedNomePrograma];
// self.programa.tentativas = [[Programa sharePrograma] obterSharedTentativas]; //passar para inteiro
// self.programa.qtdElementos = [[Programa sharePrograma]obterSharedqtdElementos];// passar para inteiro
// self.programa.tempoExposicao = [[Programa sharePrograma] obterSharedtempoExposicao];// passar para inteiro
// self.programa.tempoAtraso = [[Programa sharePrograma]obterSharedtempoAtraso]; //passar para inteiro
// self.programa.tempoEntreTentativa = [[Programa sharePrograma]obterSharedtempoEntreTentativa]; // passar para inteiro
// self.programa.isFiguraUnica = [[Programa sharePrograma] obterSharedisFiguraUnica]; // passar pra int
// self.programa.isOrdemAleatoria = [[Programa sharePrograma] obterSharedisOrdemAleatoria]; //passar pra int;
// self.programa.backgroundColor = [[Programa sharePrograma] obterSharedbackgroundColor];
// self.programa.save = [[Programa sharePrograma]obtersave];
//declarando int
int tentativas;
int qtdElementos;
double tempoExposicao;
double tempoAtraso;
double tempoEntreTentativa;
int isFiguraUnica;
int isOrdemAleatoria;
int sav;
//passando os valores pra int
// tentativas = self.programa.tentativas.intValue;
// qtdElementos = self.programa.qtdElementos.intValue;
// tempoExposicao = self.programa.tempoExposicao.doubleValue;
// tempoAtraso = self.programa.tempoAtraso.doubleValue;
// tempoEntreTentativa = self.programa.tempoEntreTentativa.doubleValue;
// isFiguraUnica = self.programa.isFiguraUnica.intValue;
// isOrdemAleatoria = self.programa.isOrdemAleatoria.intValue;
// sav = self.programa.save.intValue;
// NSLog(@"------ %d",sav);
if (sav) {
//
//
// //povoando o nomePrograma vetor com os nomes dos experimentos
// if (!self.nomeProgramas) {
// self.nomeProgramas = [[NSMutableArray alloc]init];
// }
//
// if (!self.listaProgramas) {
// self.listaProgramas = [[NSMutableArray alloc]init];
// }
//
//
// // [self.listaProgramas insertObject:self.programa atIndex:0];
//
// [self.listaProgramas addObject:self.programa];
//
//
// [self.nomeProgramas insertObject:self.programa.nomePrograma atIndex:0];
//
//
// NSLog(@"lista porgs: %@",self.listaProgramas);
//
//
// NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:0];
// [self.tableListaProgramas insertRowsAtIndexPaths:@[index] withRowAnimation:UITableViewRowAnimationAutomatic];
}
}
//caminho plist
-(NSString*)caminhoPerfil
{
NSArray *paths = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fileName = [NSString stringWithFormat:@"%@/perfil.plist",documentsDirectory];
return fileName;
}
//metodos oara poder editar as tebela
-(void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
[self.tableListaProgramas setEditing:editing animated:animated];
}
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
-(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
self.nomeProgramas = [[NSMutableArray alloc]initWithContentsOfFile:[self caminhoPerfil]];
[self.nomeProgramas removeObjectAtIndex:indexPath.row ];
[self.nomeProgramas writeToFile:[self caminhoPerfil] atomically:YES];
[self.tableListaProgramas reloadData];
}
//
@end