Class: TextFieldCell
- Inherits:
-
BaseCell
- Object
- UITableViewCell
- BaseCell
- TextFieldCell
show all
- Defined in:
- lib/project/cells/text_field_cell.rb
Constant Summary
collapse
- IDENTIFIER =
'TextFieldCell'
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
14
15
16
|
# File 'lib/project/cells/text_field_cell.rb', line 14
def has_value?
true
end
|
Instance Method Details
#icon=(icon) ⇒ Object
31
32
33
|
# File 'lib/project/cells/text_field_cell.rb', line 31
def icon=(icon)
left_view.name = icon
end
|
#initWithStyle(style, reuseIdentifier: reuse_identifier) ⇒ Object
7
8
9
10
11
|
# File 'lib/project/cells/text_field_cell.rb', line 7
def initWithStyle(style, reuseIdentifier: reuse_identifier)
super.tap do |cell|
cell.observe('ButtonCallbackWillFire', 'resign_textfield:')
end
end
|
#label=(label) ⇒ Object
23
24
25
|
# File 'lib/project/cells/text_field_cell.rb', line 23
def label=(label)
text_field.placeholder = label
end
|
#layoutSubviews ⇒ Object
62
63
64
65
|
# File 'lib/project/cells/text_field_cell.rb', line 62
def layoutSubviews
text_field.frame = [[10, 0], [300, 43]]
left_view.frame = [[0, 0], [36, 43]]
end
|
#left_view ⇒ Object
50
51
52
|
# File 'lib/project/cells/text_field_cell.rb', line 50
def left_view
@left_view ||= IconView.alloc.init
end
|
#notification_payload ⇒ Object
81
82
83
|
# File 'lib/project/cells/text_field_cell.rb', line 81
def notification_payload
{ key: key, value: value, text_field: text_field }
end
|
#resign_textfield(notification) ⇒ Object
19
20
21
|
# File 'lib/project/cells/text_field_cell.rb', line 19
def resign_textfield(notification)
text_field.resignFirstResponder if text_field.isFirstResponder
end
|
#secure=(secure) ⇒ Object
27
28
29
|
# File 'lib/project/cells/text_field_cell.rb', line 27
def secure=(secure)
text_field.secureTextEntry = secure
end
|
#text_field ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/project/cells/text_field_cell.rb', line 35
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
67
68
69
|
# File 'lib/project/cells/text_field_cell.rb', line 67
def textFieldDidBeginEditing(text_field)
post('FormCellDidBeginEditing', notification_payload)
end
|
#textFieldDidEndEditing(text_field) ⇒ Object
71
72
73
|
# File 'lib/project/cells/text_field_cell.rb', line 71
def textFieldDidEndEditing(text_field)
post('FormCellDidEndEditing', notification_payload)
end
|
#textFieldShouldReturn(text_field) ⇒ Object
75
76
77
78
79
|
# File 'lib/project/cells/text_field_cell.rb', line 75
def textFieldShouldReturn(text_field)
text_field.resignFirstResponder
true
end
|
#value ⇒ Object
54
55
56
|
# File 'lib/project/cells/text_field_cell.rb', line 54
def value
text_field.text
end
|
#value=(value) ⇒ Object
58
59
60
|
# File 'lib/project/cells/text_field_cell.rb', line 58
def value=(value)
text_field.text = value
end
|