Class: TextInputCell
- Inherits:
-
BaseCell
- Object
- UITableViewCell
- BaseCell
- TextInputCell
show all
- Defined in:
- lib/project/cells/text_input_cell.rb
Constant Summary
collapse
- IDENTIFIER =
'TextInputCell'
Instance Attribute Summary
Attributes inherited from BaseCell
#key
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseCell
#dealloc, #notification_center, #observe, #post, #selected_background_view
Class Method Details
.has_value? ⇒ Boolean
16
17
18
|
# File 'lib/project/cells/text_input_cell.rb', line 16
def has_value?
true
end
|
Instance Method Details
#icon=(icon) ⇒ Object
33
34
35
|
# File 'lib/project/cells/text_input_cell.rb', line 33
def icon=(icon)
left_view.name = icon
end
|
#initWithStyle(style, reuseIdentifier: reuse_identifier) ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/project/cells/text_input_cell.rb', line 7
def initWithStyle(style, reuseIdentifier: reuse_identifier)
super.tap do |cell|
cell.observe('ButtonCallbackWillFire', 'resign_textfield:')
cell.observe('FormWillValidate', 'resign_textfield:')
cell.observe('FormWillRender', 'resign_textfield:')
end
end
|
#label=(label) ⇒ Object
25
26
27
|
# File 'lib/project/cells/text_input_cell.rb', line 25
def label=(label)
text_field.placeholder = label
end
|
#layoutSubviews ⇒ Object
64
65
66
67
|
# File 'lib/project/cells/text_input_cell.rb', line 64
def layoutSubviews
text_field.frame = [[10, 0], [300, 43]]
left_view.frame = [[0, 0], [36, 43]]
end
|
#left_view ⇒ Object
52
53
54
|
# File 'lib/project/cells/text_input_cell.rb', line 52
def left_view
@left_view ||= IconView.alloc.init
end
|
#notification_payload ⇒ Object
83
84
85
|
# File 'lib/project/cells/text_input_cell.rb', line 83
def notification_payload
{ key: key, value: value, text_field: text_field }
end
|
#resign_textfield(notification) ⇒ Object
21
22
23
|
# File 'lib/project/cells/text_input_cell.rb', line 21
def resign_textfield(notification)
text_field.resignFirstResponder if text_field.isFirstResponder
end
|
#secure=(secure) ⇒ Object
29
30
31
|
# File 'lib/project/cells/text_input_cell.rb', line 29
def secure=(secure)
text_field.secureTextEntry = secure
end
|
#text_field ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/project/cells/text_input_cell.rb', line 37
def text_field
@text_field ||= UITextField.alloc.init.tap do |field|
field.autocorrectionType = UITextAutocorrectionTypeNo
field.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight
field.backgroundColor = UIColor.clearColor
field.clearButtonMode = UITextFieldViewModeWhileEditing
field.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter
field.leftView = left_view
field.leftViewMode = UITextFieldViewModeAlways
field.textColor = UIColor.grayColor
field.delegate = self
end
end
|
#textFieldDidBeginEditing(text_field) ⇒ Object
69
70
71
|
# File 'lib/project/cells/text_input_cell.rb', line 69
def textFieldDidBeginEditing(text_field)
post('FormCellDidBeginEditing', notification_payload)
end
|
#textFieldDidEndEditing(text_field) ⇒ Object
73
74
75
|
# File 'lib/project/cells/text_input_cell.rb', line 73
def textFieldDidEndEditing(text_field)
post('FormCellDidEndEditing', notification_payload)
end
|
#textFieldShouldReturn(text_field) ⇒ Object
77
78
79
80
81
|
# File 'lib/project/cells/text_input_cell.rb', line 77
def textFieldShouldReturn(text_field)
text_field.resignFirstResponder
true
end
|
#value ⇒ Object
56
57
58
|
# File 'lib/project/cells/text_input_cell.rb', line 56
def value
text_field.text
end
|
#value=(value) ⇒ Object
60
61
62
|
# File 'lib/project/cells/text_input_cell.rb', line 60
def value=(value)
text_field.text = value
end
|