我有一个位于键盘后面的模态弹出窗口。
如何将模态弹出窗口移动到更高的位置?
答案 0 :(得分:0)
使用此:
键盘显示和隐藏通知的注册类
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
}
答案 1 :(得分:0)
这可以解决上述情况。
我假设您正在将becomeFirstResponder
用于textField。在类中写下以模态显示的代码。
-(void)viewDidAppear:(BOOL)animated{
[self performSelector:@selector(txtFieldResponder) withObject:nil afterDelay:0.1];
}
-(void)txtFieldResponder{
[self.txt becomeFirstResponder];
}
希望这有帮助。