在UITextField中忽略制表符...(iPad应用) [英] Ignore Tab character in UITextField... (iPad app)
问题描述
我在每个单元格中都有一个带TextFields的TableView,我想要那些文本字段
忽略字符选项卡( \t
)。
I have a TableView with TextFields in each cell and I want to those textfields
ignore the character tab (\t
).
按下Tab键时, textField:shouldChangeCharactersInRange
方法未被调用
When the tab key is pressed, the textField:shouldChangeCharactersInRange
method it's not called
有谁知道怎么做?我知道iPad
键盘中没有Tab键,但是blutooth和dock的键盘会触发一个非常奇怪的行为。
Does anyone knows how to do this? I know that there is no tab key in the iPad keyboard but the blutooth and dock ones do and triggers a really weird behavior.
谢谢
推荐答案
这似乎是标签( \t
)字符的问题。此字符不像普通字符(例如a,b,c,0,1,2,...)那样处理,因此
This seems to be a problem with the tab (\t
) character. This character is not handled like normal characters (e.g. a, b, c, 0, 1, 2, ...) and thus the
- (BOOL)textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)string;
将永远不会调用委托方法。
delegate method won't ever be called.
使用例如标签的结果外部键盘或在模拟器中是当前活动的文本字段重新分配它的第一响应者状态和结果
The result of using a tab on e.g. an external keyboard or in the simulator is that a currently active textfield resigns it's first responder status and the result of
[textField nextResponder]
将成为第一响应者。
IMO目前的错误(iOS SDK 4.3)是委托方法
What IMO currently is a bug (iOS SDK 4.3) is that the delegate method
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
只调用一次(当你返回yes时)并重新选择相同的文本字段并使用再次选项卡键,将不再调用该方法。
is only called once (when you return yes) and when you reselect the same textfield and use the tab key again, the method won't be called again.
这篇关于在UITextField中忽略制表符...(iPad应用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!