将 Xamarin Forms 中的编辑器滚动到视图中 [英] Scroll editor in Xamarin Forms into view

查看:32
本文介绍了将 Xamarin Forms 中的编辑器滚动到视图中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Xamarin Forms,考虑下面的 Xaml.

Using Xamarin Forms, consider the Xaml below.

<StackLayout VerticalOptions="FillAndExpand">
   <Image x:Name="cameraImage" Source="camera.png" />
   <Label Text="Describe the image" />
   <Editor />
   <Button Text="Save" />
 </StackLayout>

这会渲染一个图像、一个编辑器和一个保存按钮.图像采用 4x3 图像比例,覆盖可用屏幕高度的大约三分之一.编辑器呈现在下方.

This renders an image, an editor and a save button. The image is in 4x3 image ratio and covers about a third of the available screen height. The editor is rendered below.

问题是键盘覆盖了iOS中的编辑器.通常是标准的 iOS 问题.

The problem is that the keyboard covers the Editor in iOS. A standard iOS issue normally.

问题是:Xamarin Forms 的处理方式是什么?

The question is: What is the Xamarin Forms way of handling this?

谢谢

//约翰

推荐答案

要使用 Xamarin.Forms 自动滚动编辑器和条目,您通常只需要将视图(在本例中为 StackLayout)打包到 ScrollView:

To get auto scroll for Editors and Entries with Xamarin.Forms, you usually just have to pack your View, in this case the StackLayout, into a ScrollView:

<ScrollView>
    <StackLayout VerticalOptions="FillAndExpand">
        <Image x:Name="cameraImage" Source="camera.png" />
        <Label Text="Describe the image" />
        <Editor />
        <Button Text="Save" />
    </StackLayout>
</ScrollView>

它应该是这样工作的,但截至今天(2014 年 6 月),有一个错误阻止它与编辑器完全兼容(它与条目配合良好).该问题是已知的,正在处理中.

That's how it's supposed to work, but as of today (June 2014) there's a bug preventing this to work fully with the Editor (it works well with Entries). The issue is known and is worked on.

[UPDATE 2014-11-20]该问题已得到解决,并将在 XF 1.3 的下一个预发布版本中提供

[UPDATE 2014-11-20]The issue has been addressed, and will be available in the next -pre release of XF 1.3

这篇关于将 Xamarin Forms 中的编辑器滚动到视图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆