-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAddNoteEventViewController.m
140 lines (95 loc) · 3.78 KB
/
AddNoteEventViewController.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
Copyright (c) 2010 Rafael Chacon
g-Cal is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
g-Cal is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with g-Cal. If not, see <http://www.gnu.org/licenses/>.
*/
#import "AddNoteEventViewController.h"
@implementation AddNoteEventViewController
@synthesize noteTextView;
-(void)done{
self.event.note = self.noteTextView.text;
[self.navigationController popViewControllerAnimated:YES];
}
-(void)cancel{
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark -
#pragma mark Table View dataSource Methods
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *kNoteCell_ID = @"noteCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kNoteCell_ID];
if (cell == nil) {
CGRect CellFrame = CGRectMake(0, 0, 300, 60);
cell = [[[UITableViewCell alloc] initWithFrame:CellFrame reuseIdentifier:kNoteCell_ID] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
UITextView *textView = self.noteTextView;
[cell.contentView addSubview:textView];
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat result = 150.0f;
return result;
}
#pragma mark -
#pragma mark Utility functions
- (UITextView *)noteTextView{
if (noteTextView == nil)
{
CGRect frame = CGRectMake(10, 5, 280, 140);
noteTextView = [[UITextView alloc] initWithFrame:frame];
noteTextView.textColor = [UIColor blackColor];
noteTextView.font = [UIFont systemFontOfSize:18.0];
noteTextView.keyboardType = UIKeyboardTypeDefault;
noteTextView.returnKeyType = UIReturnKeyDefault;
}
return noteTextView;
}
#pragma mark -
#pragma mark UIViewController functions
- (void)viewDidLoad {
self.title = NSLocalizedString(@"descriptionKey", @"Description");
self.navigationItem.prompt = NSLocalizedString(@"detailsKey", @"Set the details for this event.");
UIBarButtonItem *cancelButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"cancelKey", @"Cancel") style:UIBarButtonItemStyleBordered target:self action:@selector(cancel)];
self.navigationItem.leftBarButtonItem = cancelButtonItem;
[cancelButtonItem release];
UIBarButtonItem *saveButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"doneKey", @"Done") style:UIBarButtonItemStyleDone target:self action:@selector(done)];
self.navigationItem.rightBarButtonItem = saveButtonItem;
[saveButtonItem release];
[self noteTextView]; //to become first responder
self.noteTextView.delegate = self;
if (self.event.note != nil & [ self.event.note length] != 0)
self.noteTextView.text = self.event.note;
[super viewDidLoad];
}
- (void)viewWillAppear:(BOOL)flag {
[super viewWillAppear:flag];
[noteTextView becomeFirstResponder];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
self.noteTextView = nil;
}
- (void)dealloc {
[noteTextView release];
[super dealloc];
}
@end