我是 RubyMotion for iOS 应用程序的新手,但我使用 Objective C 进行编码。
我的要求是获取应为 UITextField 中的每个字符类型调用的委托(delegate)方法。
objective-c :我使用“shouldChangeCharactersInRange”来查找用户字符条目。
谁能建议我如何在 RubyMotion 中实现此功能以跟踪 UITextField 中的字符类型
谢谢。
问候。
最佳答案
首先,当您创建文本字段时,请确保将委托(delegate)设置为它所在的同一 View Controller 类:
textField = UITextField.alloc.initWithFrame([[10,200],[300,40]])
textField.delegate = self
然后将此方法添加到该类:
def textField(textField, shouldChangeCharactersInRange:range, replacementString:string)
# return true or false based on whether you want to allow the replacement
true
end
关于ios - RubyMotion:在 UITextField 中查找每个字符条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11020039/