Ios 键盘后面的模态弹出窗口
我在键盘后面有一个模式弹出窗口 如何将模式弹出窗口移动到更高的位置 使用以下方法: 为键盘显示和隐藏通知注册类Ios 键盘后面的模态弹出窗口,ios,ios7,modalviewcontroller,Ios,Ios7,Modalviewcontroller,我在键盘后面有一个模式弹出窗口 如何将模式弹出窗口移动到更高的位置 使用以下方法: 为键盘显示和隐藏通知注册类 NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; [center addObserver:self selector:@selector(showKeyboard:) name:UIKeyboardDidShowNotification object:nil];
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(showKeyboard:) name:UIKeyboardDidShowNotification object:nil];
[center addObserver:self selector:@selector(hideKeyboard:) name:UIKeyboardWillHideNotification object:nil];
然后实施
- (void)showKeyboard:(NSNotification *)notification {
//Change popup frame here
}
- (void)hideKeyboard:(NSNotification *)notification {
//Change popup frame to previous state
}
这是解决上述情况的方法 我假设您正在对textField使用
becomeFirstResponder
。在类中编写以下代码,该类代码以模态形式呈现
-(void)viewDidAppear:(BOOL)animated{
[self performSelector:@selector(txtFieldResponder) withObject:nil afterDelay:0.1];
}
-(void)txtFieldResponder{
[self.txt becomeFirstResponder];
}
希望这有帮助。它是模态视图控制器吗?你能用截图来说明吗?如果您只想移动UITextFields或作为modalView控制器子视图的任何内容,则可以侦听键盘DIDSHOW通知,并根据需要设置textField帧。您好,是的,这是一个具有自由形式的模态视图控制器。我想将完整的模式视图向上移动,以便您可以看到完整的登录表单。奇怪的是:我使用[userText becomeFirstResponder];键盘在模态上。如果我隐藏键盘,并把它拿回来,模态是正确定位的。。。我现在有了-(void)viewwillrespect方法中的BecomeFirstResonander…我已经有了延迟选择器,所以我认为这是解决这个问题的一个方法。所以我接受了你的答案;-)