Files
eqn.ios/Sources/Earthquake Network/ViewController/inputView/PickerViewController.m
T
2020-08-22 20:50:41 +02:00

106 lines
2.7 KiB
Objective-C

//
// PickerViewController.m
// Osteopatia
//
// Created by Beretta Luca on 17/12/12.
// Copyright (c) 2012 Luca Beretta. All rights reserved.
//
#import "PickerViewController.h"
@interface PickerViewController (){
NSArray *datiPicker;
NSNumber *indiceElemento;
NSString *elemento;
UIFont *customFont;
BOOL isVAS;
}
@end
@implementation PickerViewController
-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil dati:(NSArray *)dati
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
datiPicker = [NSArray arrayWithArray:dati];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
indiceElemento = 0;
elemento = datiPicker[[indiceElemento intValue]];
customFont = [UIFont fontWithName:@"Tahoma" size:23.0];
[self.cancellaButton setTitle:NSLocalizedString(@"Annulla", @"")];
[self.confermabutton setTitle:NSLocalizedString(@"Seleziona", @"")];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)chiudi:(id)sender {
[self.delegate chiudiView];
}
- (IBAction)inviaDati:(id)sender {
if (indiceElemento == NULL) indiceElemento = [NSNumber numberWithInt:0];
NSDictionary *dict = @{@"indice":indiceElemento, @"elemento" : elemento};
[self.delegate inviaDati:dict];
}
#pragma mark UIPickerViewDataSource
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return datiPicker.count;
}
#pragma mark UIPickerViewDelegate
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
indiceElemento = [NSNumber numberWithInteger:row];
elemento = datiPicker[row];
}
/*
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return datiPicker[row];
}
*/
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, pickerView.frame.size.width, 25)];
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor colorWithRed:0.1569 green:0.22745 blue:0.3411 alpha:1];
label.backgroundColor = [UIColor clearColor];
label.font = customFont;
label.text = datiPicker[row];
return label;
}
@end