在用键盘单击“确定”按钮之前,如何在搜索栏中使用 uitextfield 获取字符?
我有一个带有 UITextField 的 UISearchBar,当我用中文或日文向 UITextField 输入字母时,就像“w”一样,我发现键盘会显示一个面板,让用户选择一个中文单词,但在我选择一个之前word,我发现UITextField会显示字母“w”,而UISearchBarDelegate方法:
-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
不会被调用,我想在使用键盘单击“确定”按钮或使用显示面板选择单词之前使用 UITextField 获取该字母。怎么办?非常感谢!
I have a UISearchBar with UITextField, and when I input a letter to the UITextField in Chinese or Japanese, just like "w", I found that the keyboard will show a panel which let user to choice a chinese word, but before I choice a word, I found that the UITextField will show the letter “w”, and the UISearchBarDelegate method:
-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
not be called, and I want to get the letter with UITextField before I clicking the OK button with keyboard or choicing the word with showing panel. How to do? Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
方法?
您是否尝试过 UISearchBarDelegate 协议中的
Have you tried the method
in the
UISearchBarDelegate
protocol?textField.delegate = self;
您需要设置委托,然后只有委托方法才会被调用。尝试一次!
textField.delegate = self;
You need to set delegate, then only delegate method will be get called. Try this once!!