Method: UITextField_Delegate#textField

Defined in:
lib/formotion/patch/ui_text_field.rb

#textField(theTextField, shouldChangeCharactersInRange: range, replacementString: string) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/formotion/patch/ui_text_field.rb', line 131

def textField(theTextField, shouldChangeCharactersInRange:range, replacementString:string)
  if self.shouldChangeCharactersInRange_callback
    return self.shouldChangeCharactersInRange_callback.call(theTextField, range, string)
  end

  # fix for UITextField in iOS7 http://stackoverflow.com/questions/19569688/uitextfield-spacebar-does-not-advance-cursor-in-ios-7/20129483#20129483
  if BW::Device.ios_version >= "7.0"
    if range.location == theTextField.text.length && string == " "
      theTextField.text = theTextField.text.stringByAppendingString("\u00a0")
      return false
    end
  end

  true
end