当我点击文本字段时,执行此方法keyboardDidShow
,当我开始输入时,视图将会关闭。这是什么原因?这是我的代码,
else if (textField.tag==2) {
[self.viewUi setFrame:CGRectMake(0,-110,320,460)];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
}
return YES;
}
- (void)keyboardDidShow:(NSNotification *)notification
{
// Assign new frame to your view
[self.viewUi setFrame:CGRectMake(0,-110,320,460)];
}
答案 0 :(得分:0)
Alwin,这篇特别的帖子可能会帮助你完成这项工作
How to make a UITextField move up when keyboard is present?
或者在NSNotification
加载View Controller时尝试添加viewDidLoad
观察者。
答案 1 :(得分:0)
- (void)keyboardDidShow:(NSNotification *)notification
{
// Assign new frame to your view
[self.viewUi setFrame:CGRectMake(0,-110,320,460)];
}