Estudo de desenvolvimento para iPhone
Obtendo os valores das colunas do pickerView
-(IBAction) precionaButaoOK: (id) sender{
NSLog(@"Tete");
NSString* sAtividade = [itensAtividade objectAtIndex:[pickerView selectedRowInComponent:0]];
NSString* sSentimentos = [itensSentimentos objectAtIndex:[pickerView selectedRowInComponent:1]];
NSString* msg = [NSString stringWithFormat:@"Teste twit %@ and %@",sAtividade,sSentimentos];
NSLog(@"%@",msg);
}
Vincula o vetor com o pickerView (passando os dados para a camada visual)
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
switch(component){
case 0:
return [itensAtividade objectAtIndex:row];
case 1:
return [itensSentimentos objectAtIndex:row];
}
return nil;
}
Quantidade de linha em cada coluna com base no vetor
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
if(component==0){
return [itensAtividade count];
}else{
return [itensSentimentos count];
}
}
Indica que pickerView tem duas colunas
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 2;
}
Carregando um vetor de string
itensAtividade = [[NSArray alloc] initWithObjects:@"trabalho", @"esporte", nil];
Recuo de tecla em campo texto;
-(IBAction) textFieldDoneEditing: (id) sender{
[sender resignFirstResponder];
}
Assinar:
Postar comentários (Atom)
Nenhum comentário:
Postar um comentário