简体   繁体   English

有没有办法让Xamarin.Forms在我的iOS应用程序中检测软件键盘?

[英]Is there a way with Xamarin.Forms to detect the software keyboard in my iOS app?

I have a Xamarin.Forms application with a login screen. 我有一个带登录屏幕的Xamarin.Forms应用程序。 I have added code to move the controls out of the way, when one of the Entry fields gets focus. 当其中一个Entry字段获得焦点时,我添加了代码来移动控件。 I move the views back down in the Unfocus event handlers. 我在Unfocus事件处理程序中将视图向下移动。 In the simulator I can prevent the software keyboard from popping up. 在模拟器中,我可以防止软件键盘弹出。 Unfortunately my event handlers still move the view up and down even without the keyboard. 不幸的是,即使没有键盘,我的事件处理程序仍然可以上下移动视图。

Is there a way to detect the keyboard's appearance in Xamarin.Forms, while in the event handlers on the ContentPage? 有没有办法在Xamarin.Forms中检测键盘的外观,而在ContentPage上的事件处理程序中?

我不认为开箱即用支持,因此我会使用DependencyService并自行实现。

You could use ContentPage.LayoutChanged event. 您可以使用ContentPage.LayoutChanged事件。

It works because the keyboard doesn't display over the content page as one would guess, but under it, in the same layer, so it push the page up. 它之所以有效,是因为键盘不会像人们猜测的那样显示在内容页面上,而是在同一层中显示,因此它会向上推动页面。

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

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