RubyMotion: Find each character entry in UITextField
-
14-06-2021 - |
Domanda
I am new to RubyMotion for iOS app, but I coded using Objective C.
My requirement is to get the delegate method which should be called for every char type in UITextField.
Objective C: I used "shouldChangeCharactersInRange" for finding the user character entry.
Can you anyone suggest me how to implement this function in RubyMotion for tracking character type in UITextField
Thank you.
Regards.
Soluzione
First, when you create the text field, make sure you set the delegate to the same View Controller class it's in:
textField = UITextField.alloc.initWithFrame([[10,200],[300,40]])
textField.delegate = self
Then add this method to that class:
def textField(textField, shouldChangeCharactersInRange:range, replacementString:string)
# return true or false based on whether you want to allow the replacement
true
end
Altri suggerimenti
I like the BubbleWrap syntax:
textField.when(UIControlEventEditingChanged) do
# something
end
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow