输入文字键盘消失

时间:2018-03-09 12:49:42

标签: c# xamarin.forms xamarin.ios

我正在使用PCL使用Xamarin表单创建移动应用程序。 iOS中的文本框始终隐藏在键盘中,但此部分在Android中完美运行。下面是我的Xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MYDriver.List"             
             WidthRequest="20" BackgroundColor="#ffffff" >   
    <ContentPage.Content >        
            <StackLayout x:Name="InBoundlayout">             
             <StackLayout x:Name="ToolBar" Style="{StaticResource ToolbarOuter}" Padding="0,20,0,0">
                <StackLayout Style="{StaticResource ToolbarInner1}">

                    <Image Source="back3.png" >
                        <Image.GestureRecognizers>
                            <TapGestureRecognizer
                      Tapped="Back_Clicked"  />
                        </Image.GestureRecognizers>
                    </Image>
                </StackLayout>

                <StackLayout Style="{StaticResource ToolbarInner1} " >
                    <Image Source="home3.png">
                        <Image.GestureRecognizers>
                            <TapGestureRecognizer
                      Tapped="Home_Clicked"  />
                        </Image.GestureRecognizers>
                    </Image>
                </StackLayout>
                <StackLayout Style="{StaticResource ToolbarInner1}" >
                    <Image x:Name="PicTorchLight" >
                        <Image.GestureRecognizers>
                            <TapGestureRecognizer Tapped="TorchLight_Clicked"  />
                        </Image.GestureRecognizers>
                    </Image>
                </StackLayout>
                <StackLayout Style="{StaticResource ToolbarInner2}">
                    <Label x:Name="lblUserName" Style="{StaticResource ToolbarLabel}" />
                    <Image Source="logout.png">
                        <Image.GestureRecognizers>
                            <TapGestureRecognizer
                      Tapped="Logout_Clicked"  />
                        </Image.GestureRecognizers>
                    </Image>
                </StackLayout>
            </StackLayout>           
             <StackLayout x:Name="layoutHead" Style="{StaticResource HeadColour}" Margin="0,-5">

                <StackLayout Spacing="0" Orientation="Horizontal" HorizontalOptions="Start">
                    <Label Text="  #" Style="{StaticResource HeadForAllorderDetails}" />
                </StackLayout>

                <StackLayout Spacing="0" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                    <Label Text="Order No" Style="{StaticResource HeadForAllorderDetails}" />
                </StackLayout>

                <StackLayout Spacing="0" Orientation="Horizontal" HorizontalOptions="StartAndExpand">
                    <Label Text="         Ref" Style="{StaticResource HeadForAllorderDetails}" />
                </StackLayout>

                <StackLayout Spacing="0" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                    <Label Text="Dropoff" Style="{StaticResource HeadForAllorderDetails}" />
                </StackLayout>

                <StackLayout Spacing="0" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                    <Label Text="          Items" Style="{StaticResource HeadForAllorderDetails}" />
                </StackLayout>

                <StackLayout Spacing="0" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                    <Label Text="Status" Style="{StaticResource HeadForAllorderDetails}" />
                </StackLayout>
            </StackLayout>

             <StackLayout x:Name="listViewOredr1">
                        <ListView x:Name="listViewOredr" ItemTapped="OnActivitySelected" HasUnevenRows="True"  >
                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <ViewCell>
                                        <Frame   HasShadow="True" OutlineColor="Silver"   Padding="3">
                                            <Grid BackgroundColor="{Binding RowColour}" ColumnSpacing="2" Padding="2" >

                                              <StackLayout x:Name="rr"  Orientation="Horizontal" HeightRequest="35" BackgroundColor="{Binding RowColour}" Padding="10">

                                                    <StackLayout Spacing="0" BackgroundColor="{Binding RowColour}" Orientation="Horizontal" HorizontalOptions="Start">
                                                        <Label FontSize="10" TextColor="#707070" Text="{Binding DROPROUTEPOS_}" HorizontalOptions="StartAndExpand" VerticalOptions="Center"/>
                                                    </StackLayout>

                                                    <StackLayout Spacing="0" BackgroundColor="{Binding RowColour}" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                                                        <Label FontSize="10" TextColor="#707070" Text="{Binding ORDERNUM}" HorizontalOptions="StartAndExpand" VerticalOptions="Center"/>
                                                    </StackLayout>

                                                    <StackLayout Spacing="0" BackgroundColor="{Binding RowColour}" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                                                        <Label FontSize="10" TextColor="#707070" Text="{Binding REF}" HorizontalOptions="StartAndExpand" VerticalOptions="Center" />
                                                    </StackLayout>

                                                    <StackLayout Spacing="0" BackgroundColor="{Binding RowColour}" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                                                        <Label FontSize="10" TextColor="#707070" Text="{Binding DROPOFF}" HorizontalOptions="StartAndExpand" VerticalOptions="Center" />
                                                    </StackLayout>

                                                    <StackLayout Spacing="0" BackgroundColor="{Binding RowColour}" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                                                        <Label FontSize="10" TextColor="#707070" Text="{Binding ItemScanStatus}" HorizontalOptions="StartAndExpand" VerticalOptions="Center" />
                                                    </StackLayout>

                                                    <StackLayout Spacing="0" BackgroundColor="{Binding RowColour}" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                                                        <Image Aspect="AspectFit" HorizontalOptions="StartAndExpand" VerticalOptions="Center" HeightRequest = "20" WidthRequest="20" Source = "{Binding ImageStatus}"  />
                                                    </StackLayout>
                                                </StackLayout>

                                           </Grid>
                                        </Frame>
                                    </ViewCell>
                                </DataTemplate>
                            </ListView.ItemTemplate>
                        </ListView>
                    </StackLayout>

             <StackLayout x:Name="layoutouterFrame" BackgroundColor="Green" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                <Frame Padding = "5" BackgroundColor="#ffffff">
                    <StackLayout Orientation="Horizontal">
                        <Grid x:Name="grid">                           
                        </Grid>                        
                    </StackLayout>
                </Frame>
            </StackLayout>

             <StackLayout x:Name="layoutForBluetooth" HeightRequest = "200"  BackgroundColor="#5DCBEE" Orientation="Horizontal" HorizontalOptions="FillAndExpand">
                       <Frame HorizontalOptions="FillAndExpand" OutlineColor="Black" HasShadow="True">-->
                        <Grid>
                            <Label Text="Scan Your Barcode" x:Name="lblDriverNumber" TextColor="Black" FontSize="Medium" HorizontalOptions="FillAndExpand" Margin="0,10" />
                            <Entry x:Name="txtentry" FontSize="Medium" TextColor="Black" WidthRequest="400" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand" Margin="0,10" />
                        </Grid>
                        </Frame> 
                    </StackLayout>

            </StackLayout>         
    </ContentPage.Content>
</ContentPage> 

请告诉我如何停止键盘隐藏上面XAML中<Entry x:Name="txtentry"的文本框。

1 个答案:

答案 0 :(得分:1)

这是iOS上的一个典型问题,而且还有一个现成的nuget插件,您需要将其导入到您的应用并进行初始化。它将检查键盘是否未隐藏已编辑的文本框,并在需要时将整个页面向上移动。

https://www.nuget.org/packages/Xam.Plugins.Forms.KeyboardOverlap/