Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.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
Objective c 键盘隐藏和显示方法多次在另一个视图上调用_Objective C_Iphone - Fatal编程技术网

Objective c 键盘隐藏和显示方法多次在另一个视图上调用

Objective c 键盘隐藏和显示方法多次在另一个视图上调用,objective-c,iphone,Objective C,Iphone,当我们在另一个视图上时,我的键盘将隐藏并显示方法调用。 这是我的第一个观点 将显示“打开视图” [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name: UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self sele

当我们在另一个视图上时,我的键盘将隐藏并显示方法调用。 这是我的第一个观点

将显示“打开视图”

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name: UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillBeHidden:) name:UIKeyboardWillHideNotification object:nil];
在视图中,将消失

-(void)viewWillDisappear:(BOOL)animated
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidHideNotification object:nil];
}
在第二个视图中,他们的文本字段处于编辑状态
他们称我的键盘为隐藏代码。这不是我想要的。

您需要删除
UIKeyboardWillShowNotification
UIKeyboardWillHideNotification
的观察者,而不是
UIKeyboardDidShowNotification
UIKeyboardDidenotification
。这可能会解决您的问题