#import "SensorAddDeleteViewController.h"
#import "ABServices.h"
#import "FormatWeekListViewController.h"
@interface
SensorAddDeleteViewController ()
@end
@implementation
SensorAddDeleteViewController
@synthesize
m_pickerSensor;
@synthesize
m_mutArrSensorList;
- (
id
)initWithNibName:(
NSString
*)nibNameOrNil bundle:(
NSBundle
*)nibBundleOrNil
{
self
= [
super
initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if
(
self
) {
}
return
self
;
}
- (
void
)viewDidLoad
{
[
super
viewDidLoad];
self
.view.backgroundColor = [UIColor colorWithPatternImage:K_contentsOfFile(@
"Background"
, @
"png"
)];
NSMutableArray
*mutArrSensorList = [[
NSMutableArray
alloc] initWithArray:[FormatWeekListViewController resultAllSersonName]];
self
.m_mutArrSensorList = mutArrSensorList;
[mutArrSensorList release];
UIPickerView *pickerSensor = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 100, 320, 220)];
self
.m_pickerSensor = pickerSensor;
[pickerSensor release];
m_pickerSensor.delegate =
self
;
m_pickerSensor.dataSource =
self
;
m_pickerSensor.showsSelectionIndicator =
YES
;
[
self
.view addSubview:m_pickerSensor];
[m_pickerSensor selectRow:[m_mutArrSensorList count] inComponent:0 animated:
YES
];
}
- (
void
)didReceiveMemoryWarning
{
[
super
didReceiveMemoryWarning];
}
-(
void
)dealloc
{
[m_pickerSensor release];
[m_mutArrSensorList release];
[
super
dealloc];
}
#pragma mark -
#pragma mark pickview delegate
- (
NSInteger
)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return
1;
}
- (
NSInteger
)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(
NSInteger
)component
{
return
[m_mutArrSensorList count]*50;
}
- (
NSString
*)pickerView:(UIPickerView *)pickerView titleForRow:(
NSInteger
)row forComponent:(
NSInteger
)component
{
return
[m_mutArrSensorList objectAtIndex:(row%[m_mutArrSensorList count])];
}
- (
void
)pickerView:(UIPickerView *)pickerView didSelectRow:(
NSInteger
)row inComponent:(
NSInteger
)component
{
NSUInteger
max = 0;
NSUInteger
base10 = 0;
if
(component == 0)
{
max = [m_mutArrSensorList count]*50;
base10 = (max/2)-(max/2)%[m_mutArrSensorList count];
[pickerView selectRow:[pickerView selectedRowInComponent:component]%[m_mutArrSensorList count]+base10 inComponent:component animated:
false
];
}
}
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(
NSInteger
)row forComponent:(
NSInteger
)component reusingView:(UIView *)view {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(12.0f, 0.0f, [pickerView rowSizeForComponent:component].width-12, [pickerView rowSizeForComponent:component].height)];
label.text = [m_mutArrSensorList objectAtIndex:(row%[m_mutArrSensorList count])];
label.textAlignment = UITextAlignmentCenter;
return
[label autorelease];
}
@end