-
Notifications
You must be signed in to change notification settings - Fork 0
/
AllowanceDayEditor.m
61 lines (50 loc) · 2.03 KB
/
AllowanceDayEditor.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
//
// AllowanceDayEditor.m
// Allowance
//
// Created by Pablo Collins on 6/27/10.
//
#import "AllowanceDayEditor.h"
@implementation AllowanceDayEditor
@synthesize reloadableParent;
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Allowance Day";
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
int i = [defaults integerForKey:@"payDay"];
[dayPicker selectRow:i-1 inComponent:0 animated:NO];
UIImage *blueImage = [UIImage imageNamed:@"blueButton.png"];
UIImage *whiteImage = [UIImage imageNamed:@"whiteButton.png"];
CGRect f1 = CGRectMake(10, 240, 300, 40);
UIButton *btn = [AllowanceAppDelegate newButtonWithTitle:@"OK"
target:self
selector:@selector(save:)
frame:f1
image:whiteImage
imagePressed:blueImage
darkTextColor:YES];
[self.view addSubview:btn];
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return 7;
}
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
return 200;
}
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component {
return 42;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [WeekDays nameForNum:[NSNumber numberWithInt:row+1]];
}
- (IBAction)save:(id)sender {
NSInteger weekDay = [dayPicker selectedRowInComponent:0] + 1;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setInteger:weekDay forKey:@"payDay"];
[reloadableParent readAndReload];
[self.navigationController popViewControllerAnimated:YES];
}
@end