键盘背后的模态弹出窗口

时间:2013-11-20 13:30:16

标签: ios ios7 modalviewcontroller

我有一个位于键盘后面的模态弹出窗口。

如何将模态弹出窗口移动到更高的位置?

enter image description here

2 个答案:

答案 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];
}

希望这有帮助。