motion-prime/sections/table/table_delegate.rb in motion-prime-1.0.4 vs motion-prime/sections/table/table_delegate.rb in motion-prime-1.0.5
- old
+ new
@@ -73,7 +73,38 @@
end
def scrollViewDidEndDragging(scroll, willDecelerate: will_decelerate)
table_section.scroll_view_did_end_dragging(scroll, willDecelerate: will_decelerate)
end
+
+ def textFieldShouldReturn(text_field)
+ table_section.on_input_return(text_field)
+ end
+ def textFieldShouldBeginEditing(text_field)
+ text_field.respond_to?(:readonly) ? !text_field.readonly : true
+ end
+ def textFieldDidBeginEditing(text_field)
+ table_section.on_input_edit_begin(text_field)
+ end
+ def textFieldDidEndEditing(text_field)
+ table_section.on_input_edit_end(text_field)
+ end
+ def textViewDidBeginEditing(text_view)
+ table_section.on_input_edit_begin(text_view)
+ end
+ def textViewDidEndEditing(text_view)
+ table_section.on_input_edit_end(text_view)
+ end
+ def textViewDidChange(text_view) # bug in iOS 7 - cursor is out of textView bounds
+ line = text_view.caretRectForPosition(text_view.selectedTextRange.start)
+ overflow = line.origin.y + line.size.height -
+ (text_view.contentOffset.y + text_view.bounds.size.height - text_view.contentInset.bottom - text_view.contentInset.top)
+ if overflow > 0
+ offset = text_view.contentOffset
+ offset.y += overflow + text_view.textContainerInset.bottom
+ UIView.animate(duration: 0.2) do
+ text_view.setContentOffset(offset)
+ end
+ end
+ end
end
end
\ No newline at end of file