-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFFFormTextViewFieldCell.m
More file actions
59 lines (47 loc) · 1.49 KB
/
FFFormTextViewFieldCell.m
File metadata and controls
59 lines (47 loc) · 1.49 KB
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
//
// FFFormTextViewCell.m
// prophets-ios
//
// Created by Benjamin Roesch on 11/12/12.
// Copyright (c) 2012 Benjamin Roesch. All rights reserved.
//
#import "FFFormTextViewFieldCell.h"
#import "FFFormTextViewField.h"
#import "UIToolbar+Additions.h"
@implementation FFFormTextViewFieldCell
-(void)setFormField:(FFFormField *)formField{
FFFormTextViewField *field = (FFFormTextViewField *)formField;
self.textView.text = field.currentValue;
self.textView.returnKeyType = field.returnKeyType;
self.placeholderLabel.text = field.labelName;
self.textView.inputAccessoryView = [UIToolbar toolbarWithDoneButtonForResponder:self.textView];
[super setFormField:formField];
}
-(void)layoutSubviews{
[super layoutSubviews];
if(self.formField.shouldBecomeFirstResponder){
self.formField.shouldBecomeFirstResponder = NO;
[self makeFirstResponder];
}
}
-(void)awakeFromNib{
[super awakeFromNib];
self.textView.delegate = self;
}
-(void)textViewDidChange:(UITextView *)textView{
self.formField.currentValue = textView.text;
}
-(void)textViewDidBeginEditing:(UITextView *)textView{
if (!self.placeholderLabel.hidden) {
self.placeholderLabel.hidden = YES;
}
}
-(void)textViewDidEndEditing:(UITextView *)textView{
if ((!textView.text || [textView.text isEqualToString:@""]) && self.placeholderLabel.hidden) {
self.placeholderLabel.hidden = NO;
}
}
-(void)makeFirstResponder{
[self.textView becomeFirstResponder];
}
@end