我有一个定制的UIAlertView.I,该AlertView中有一个UITextField,一旦显示,它就成为第一个响应者。现在,当用户触摸AlertView中的其他位置时,我需要关闭该UITextField的键盘。我已经为此接触了事件。在UIAlertView中关闭UITextField的键盘
一切都很到位并且工作正常,除非我在UITextField上调用resignFirstResponder时,它将从第一响应者辞职,但键盘不会被解除。有什么办法可以解雇那个键盘吗?
我一直在寻找的解决方案,并发现了一个类似的帖子here没有答案
如果有人能找到一条出路请让我知道。我甚至尝试了以下方法,但它不能正常工作
UIWindow* tempWindow;
// Because we cant get access to the UIKeyboard throught the SDK we will just use UIView.
// UIKeyboard is a subclass of UIView anyways
UIView* keyboard;
// Check each window in our application
for(int c = 0; c < [[[UIApplication sharedApplication] windows] count]; C++)
{
// Get a reference of the current window
tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:c];
for(int i = 0; i < [tempWindow.subviews count]; i++)
{
// Get a reference to the current view
keyboard = [tempWindow.subviews objectAtIndex:i];
// Loop through all views in the current window
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES){
[keyboard removeFromSuperview];
}
}
}
这真的帮助!谢谢! – hawshy 2012-03-02 09:37:03
无论如何有多少firstResponders? – 2012-11-13 11:05:45