-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFFFormTextFieldCell.m
More file actions
49 lines (38 loc) · 1.3 KB
/
FFFormTextFieldCell.m
File metadata and controls
49 lines (38 loc) · 1.3 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
//
// TextFieldCell.m
// Inkling Mobile
//
// Created by Benjamin Roesch on 7/6/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "FFFormTextFieldCell.h"
#import "FFFormTextField.h"
#import "UIToolbar+Additions.h"
@implementation FFFormTextFieldCell
-(void)awakeFromNib{
[super awakeFromNib];
[self.textField addTarget:self action:@selector(fieldChanged) forControlEvents:UIControlEventEditingChanged];
self.textField.inputAccessoryView = [UIToolbar toolbarWithDoneButtonForResponder:self.textField];
}
-(void)layoutSubviews{
[super layoutSubviews];
if(self.formField.shouldBecomeFirstResponder){
self.formField.shouldBecomeFirstResponder = NO;
[self makeFirstResponder];
}
}
-(void)fieldChanged{
self.formField.currentValue = self.textField.text;
}
-(void)setFormField:(FFFormField *)formField{
FFFormTextField *field = (FFFormTextField *)formField;
self.textField.placeholder = field.labelName;
self.textField.secureTextEntry = field.secure;
self.textField.returnKeyType = field.returnKeyType;
self.textField.text = field.currentValue ? [NSString stringWithFormat:@"%@", field.currentValue] : nil;
[super setFormField:formField];
}
-(void)makeFirstResponder{
[self.textField becomeFirstResponder];
}
@end