键盘滑回后 UIPopoverController 未移至原始位置
我正在 iPad 中显示带有 UINavigation 栏的弹出框。在第二个视图中,我有一个可以显示键盘的 UISearchController。键盘将弹出窗口向上推,这很好,但是如果我现在按下 UINavigation 栏上的“后退”按钮,它会关闭键盘,这很好,但弹出窗口不会滑回其原始位置。有人知道如何解决这个问题吗?谢谢!
I'm displaying a popover in iPad with a UINavigation bar. On the second view, I have a UISearchController that can display a keyboard. The keyboard pushes the popover up, which is fine, however if I now push the 'back' button on the UINavigation bar it dismisses the keyboard which is fine, but the popover doesn't slide back down to its original position. Anyone know how to fix that? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,所以我实际上弄清楚了(我相信)你的问题在问什么……以防万一有人从谷歌上偶然发现这个问题,我想我会回答我是如何做到的。这感觉像是一项黑客工作,但我找不到任何其他方法来做到这一点。
在调出键盘的控制器中,我让它在键盘关闭时发布通知:
然后回到控制 UIPopover 的主屏幕控制器,我添加了一个侦听器:
在 init 内部。请务必记住删除 dealloc 中的侦听器,以实现良好的编程实践:
因此,每当我收到键盘消失的通知时,我都会获得对弹出窗口显示的按钮的引用,然后直接将其重新显示it:
}
我没有添加任何检查它是哪个弹出窗口,但如果我有超过 1 种类型的弹出窗口/按钮,我可以轻松地做到这一点。但这是你可以遵循的基本前提。
希望有帮助!
Ok so I actually figured out (I believe) what your question was asking...and just in case anyone stumbles upon this from google, I figured I'd answer how I did it. It feels like a hack job but I haven't been able to find any other way to do it.
In the controller that brings up the keyboard,I had it post a notification whenever the keyboard dismisses:
Then back on my home screen controller, that controls the UIPopover, I added a listener:
inside the init. Be sure to remember to remove the listener in your dealloc for good programming practice:
So then whenever I get notification that the keyboard disappears, I get a reference to the button that the popover shows up from, and just have it re-appear directly from it:
}
I haven't added any checks for which popup it is, but I can easily do that if I have more than 1 type of popover / button that it would appear from. But that's the basic premise that you can go from.
Hope it helps!
您还可以在初始化程序中的某个位置注册 UIKeyboardDidHideNotification。
这段代码将弹出窗口向后移动:
我没有让它在没有延迟的情况下工作,但这对于我当前的项目来说似乎是可以接受的。希望它能帮助某人。
You could also register for the UIKeyboardDidHideNotification somewhere in the initializer.
This code moves the popover back:
I didn't get it working without the delays, but this seems to be acceptable for my current project. Hope it helps someone.
按“后退”按钮后,您应该手动为搜索字段调用
resignFirstResponder
(例如在viewDidDisappear
内)。这应该会有所帮助,但当设备处于横向且左侧有 ome 按钮时,该问题在 iOS 4 下仍然会重现
After you press the Back button you should manually call
resignFirstResponder
for the search field (for example insideviewDidDisappear
).This should help, but the issue still will be reproduced under iOS 4 when the device is in Landscape orientation with Hthe ome button on the left side