简体   繁体   English

如何呈现模态视图,而不与键盘重叠?

[英]How to present a modal view, not overlapped by the keyboard?

I am using FPPopover . 我正在使用FPPopover Everything works well until I want to present the popover when there is a keyboard. 一切正常,直到我想在有键盘的情况下显示弹出窗口为止。 The sequence of events are: 事件的顺序是:

  • click on a text field 单击一个文本字段
  • keyboard shows up as usual 键盘照常显示
  • click a button to trigger popover 单击一个按钮触发弹出窗口

    在此处输入图片说明

Here is the FPPopover code to add its view: 这是添加其视图的FPPopover代码:

NSArray *windows = [UIApplication sharedApplication].windows;
if(windows.count > 0)
{
      _parentView=nil;
    _window = [windows objectAtIndex:0];
    //keep the first subview
    if(_window.subviews.count > 0)
    {
        _parentView = [_window.subviews objectAtIndex:0];
        [_parentView addSubview:self.view];
        [_viewController viewDidAppear:YES];
    }

}

How can I make the popover view not overlapped by the keyboard? 如何使弹出窗口视图与键盘重叠?

Did you want to have the keyboard visible at all times? 您想一直显示键盘吗? If not, have your view dismiss the keyboard when the modal view is presented. 如果不是,请在显示模式视图时关闭键盘视图。

You can do this by calling sending resignFirstResponder to a view object (such as a textView). 您可以通过调用将resignFirstResponder发送到视图对象(例如textView)来实现。

Once the modal view is closed, send becomeFirstResponder. 模态视图关闭后,发送成为firstResponder。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM