-
Notifications
You must be signed in to change notification settings - Fork 0
/
DatePickerViewController.m
111 lines (77 loc) · 2.72 KB
/
DatePickerViewController.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
//
// DatePickerViewController.m
// Metasome
//
// Created by Omar Metwally on 9/5/13.
// Copyright (c) 2013 Logisome. All rights reserved.
//
#import "DatePickerViewController.h"
#import "TextFormatter.h"
@interface DatePickerViewController ()
@end
@implementation DatePickerViewController
-(id)init
{
self = [super init];
if (self) {
}
return self;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// If an event (and corresponding date) already exist, initialize the UIDatePicker
if ( [[self parentDateController] eventSelected] ) {
[[self datePicker] setDate:[[[self parentDateController] eventSelected] date]];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[TextFormatter formatTitleLabel:titleLabel withTitle:@"Select New Date"];
[[self navigationItem] setTitleView:titleLabel];
}
}
-(void)goBack
{
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)cancelSelected:(id)sender {
[[self navigationController] popViewControllerAnimated:YES];
}
- (IBAction)okSelected:(id)sender {
self.navigationController.navigationBar.hidden = NO;
// nevc points to NewEventViewController
[[[self parentDateController] eventSelected] setDate:[[self datePicker] date] ];
[[[self parentDateController] view] setNeedsDisplay];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd MMM yyyy"];
self.parentDateController.dateSelected = [[self datePicker] date];
[[[self parentDateController] dateLabel] setText:[dateFormatter stringFromDate:self.parentDateController.dateSelected]];
[[self navigationController] popViewControllerAnimated:YES];
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(okSelected:)];
UIBarButtonItem *cancelButon = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelSelected:)];
[[self navigationItem] setRightBarButtonItem:saveButton];
[[self navigationItem] setLeftBarButtonItem:cancelButon];
}
-(void)newEventViewController:(NewEventViewController *)nevc handleObject:(id)object
{
}
-(void)formatTextView:(UITextView *)tv
{
}
-(void)formatLabel:(UILabel *)label
{
}
@end