因此,我使用核心图形创建了一个自定义文本视图,并使其符合 UITextInput 和 UITextInputTraits 协议。除了一种奇怪/烦人的行为外,一切都很好。键盘正确显示自动更正建议,但当用户点击标有“X”的建议时,它不会忽略该建议,而是插入该建议。我已经检查过了,在所有其他程序中,点击带有“X”的建议会驳回该建议。我该如何解决?
在我的自定义文本视图中,我有以下 iVar:
//UITextInputTraits
UITextAutocapitalizationType _uiAutoCap;
UITextAutocorrectionType _uiAutoCorrect;
UITextSpellCheckingType _uiSpellCheck;
UIKeyboardType _uiKeyboard;
UIKeyboardAppearance _uiKeyboardAppearance;
UIReturnKeyType _uiReturnType;
BOOL _uiEnableAutoReturn;
BOOL _uiSecureText;
合成到适当的 TextInputTraits 属性:
@synthesize autocapitalizationType=_uiAutoCap, autocorrectionType=_uiAutoCorrect, spellCheckingType=_uiSpellCheck, keyboardType=_uiKeyboard, keyboardAppearance=_uiKeyboardAppearance, returnKeyType=_uiReturnType, inputDelegate=_uiTextDelegate, enablesReturnKeyAutomatically=_uiEnableAutoReturn, secureTextEntry=_uiSecureText;
并且它们使用以下默认值进行初始化:
_uiAutoCorrect = UITextAutocorrectionTypeDefault;
_uiSpellCheck = UITextSpellCheckingTypeDefault;
_uiKeyboardAppearance = UIKeyboardAppearanceDefault;
_uiAutoCap = UITextAutocapitalizationTypeNone;
_uiReturnType = UIReturnKeyDefault;
_uiEnableAutoReturn = NO;
_uiSecureText = NO;
_uiKeyboard = UIKeyboardTypeDefault;
有任何想法吗?