在我的应用程序中,我在后台(NSOperationQueue)做了一些搜索,一旦完成并在主队列上的UITableView中显示结果,但UIKeyboardType总是被重置。
用户更改当前UIKeyboardType后,如何获取当前user?
我尝试在搜索之前将类型存储在一个变量中,但是执行搜索的textField返回的不是可见的键盘的实际类型,而是默认设置为的UIKeyboardType。
发布于 2013-02-22 20:38:21
以下是我为解决问题所做的工作。我检查了一下他们在搜索字段中输入的最后一个字符是什么,并据此确定了UIKeyboardType:
if ([searchText length]>0) {
NSRange nond = [[searchText substringFromIndex:[searchText length]-1] rangeOfCharacterFromSet:[[NSCharacterSet lowercaseLetterCharacterSet] invertedSet]];
if (NSNotFound == nond.location) {
self.currentKeyboardType = UIKeyboardTypeDefault;
} else {
self.currentKeyboardType = UIKeyboardTypeNumberPad;
}
}然后,在搜索完成后,我将UIKeyboardType设置为此值。在我看来,在默认情况下,我的应用程序会根据我为UISearchBar文本字段设置的默认键盘切换回键盘。这对我来说很有效。
发布于 2013-02-21 23:33:31
您可以使用textField.keyboardType并获取textField的键盘类型...
https://stackoverflow.com/questions/15006074
复制相似问题