rkb*_*rkb 4 iphone iphone-softkeyboard
我有一个自定义的UIAlertView.我在该AlertView中有一个UITextField,它一出现就成为firstResponder.现在,当用户触摸AlertView中的其他位置时,我需要关闭该UITextField的键盘.我已经接触过此次活动.
一切都到位并且工作正常,除非我在UITextField上调用resignFirstResponder,它从第一个响应者辞职但键盘没有被解雇.有没有办法解雇那个键盘.
我一直在寻找解决方案,并在这里发现了类似的帖子,没有答案
如果有人能找到出路请告诉我.我甚至尝试了以下方式,但它不起作用
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];
}
}
}
Run Code Online (Sandbox Code Playgroud)
小智 7
你必须在UIAlertField上调用resignFirstResponder,
例如:
[textField resignFirstResponder];[alertView resignFirstResponder];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4865 次 |
| 最近记录: |