Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 抛弃iPad键盘_Iphone_Ios_Ipad_Keyboard - Fatal编程技术网

Iphone 抛弃iPad键盘

Iphone 抛弃iPad键盘,iphone,ios,ipad,keyboard,Iphone,Ios,Ipad,Keyboard,我正在为iPhone和iPad创建一个iOS应用程序,我的一些屏幕上有UITextFields。我希望当用户点击文本框时键盘被关闭。为此,我编写了以下代码: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [firstName resignFirstResponder]; [lastName resignFirstResponder]; [email resignFirstRespo

我正在为iPhone和iPad创建一个iOS应用程序,我的一些屏幕上有UITextFields。我希望当用户点击文本框时键盘被关闭。为此,我编写了以下代码:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
     [firstName resignFirstResponder];
     [lastName resignFirstResponder];
     [email resignFirstResponder];
     [password resignFirstResponder];
     [retypePassword resignFirstResponder];
}
这适用于iPhone,但不适用于iPad上的键盘。我在网上搜索过,所有的建议都不起作用。主要建议是:

- (BOOL)disablesAutomaticKeyboardDismissal {
       return NO;
}
但这仍然不起作用?
任何帮助都将不胜感激。

您的控制器如何显示?如果它是以表格形式呈现的,那么当发生这种情况时,iOS有时不允许您在表格移动时关闭键盘。这只会带来更好的行为。你是否确保变量链接到IB中的iPad视图(如果你正在使用它)?@geogreen-是的,我正在使用表单以模式呈现它。谢谢你的解释。这有什么办法吗?我不明白为什么它能在iPhone上工作,但不能在iPad上工作。在iPhone上,你只能全屏显示,而在iPad上,当键盘显示时,它会显示在屏幕更高位置的窗口中。为了避免移动太多,iOS通常会保持这种状态。我以前也遇到过同样的问题,花了很长时间试图解决它。我唯一的选择是以另一种风格呈现。我使用同样的方法-(BOOL)DisableAutomatickeyboarddisassal。。在我看来,它工作得很好。。。尝试添加[self.view endEditing:YES];用你的方法
Add this method to .h file, 
-(IBAction)fn_resign:(id)sender;


Inherit your XIB to UIControl and just add following method to the view.

And in file's owner assign this method to view.

in .m:
-(IBAction)fn_resign:(id)sender{
   //Hide you keyboard.
}