Xamarin Forms IOS "Entry"不可编辑



我正在使用Xamarin.Forms来构建我的应用程序。在登录页面中,我有以下布局

<ScrollView>
    <Grid 
        RowSpacing="{StaticResource MediumSpacing}" 
        ColumnSpacing="{StaticResource MediumSpacing}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <!--Two stackLayouts-->
        <!--StackLayout 1-->
        <StackLayout Spacing="0" Padding="0">
            <!--Three stacklouts here-->
            <!--First-->
            <StackLayout>
                <StackLayout.Spacing>
                    <OnPlatform x:TypeArguments="x:Double" Android="12" iOS="30" WinPhone="12"/>
                </StackLayout.Spacing>
                <StackLayout.Padding>
                    <OnPlatform x:TypeArguments="Thickness" Android="32,24,32,24" iOS="16,24,16,24" WinPhone="32,24"/>
                </StackLayout.Padding>
                <imagecircle:CircleImage
                    HorizontalOptions="Center"
                    VerticalOptions="Center"
                    WidthRequest="95" HeightRequest="95"
                    BorderColor="{StaticResource Primary}"
                    Aspect="AspectFill"
                    x:Name="CircleImageAvatar"/>
                <Label HorizontalTextAlignment="Center"
                   HorizontalOptions="FillAndExpand"
                   StyleId="LoginPageIdentifier"
                   LineBreakMode="WordWrap"
                   FontSize="Large"
                   TextColor="{DynamicResource DetailTextColor}"
                   Text="Single Sign On">
                    <Label.FontSize>
                        <OnPlatform x:TypeArguments="x:Double" Android="15" iOS="15" WinPhone="15"/>
                    </Label.FontSize>
                </Label>
            </StackLayout>
            <!--Second Stack Layout-->
            <StackLayout>
                <StackLayout.Padding>
                    <OnPlatform x:TypeArguments="Thickness" Android="32,0" iOS="32,0" WinPhone="32,0"/>
                </StackLayout.Padding>
                <StackLayout.Spacing>
                    <OnPlatform x:TypeArguments="x:Double" Android="0" iOS="15" WinPhone="10"/>
                </StackLayout.Spacing>
                <toolkit:EntryLine
                   Text="{Binding Email}" 
                   Keyboard="Email"
                   HorizontalOptions="FillAndExpand"
                   Placeholder="Email Address"
                   x:Name="EntryEmail"
                   StyleId="EmailTextField"
                   BorderColor="#ECECEC">
                    <toolkit:EntryLine.HorizontalTextAlignment>
                        <OnPlatform x:TypeArguments="TextAlignment" iOS="Center"/>
                    </toolkit:EntryLine.HorizontalTextAlignment>
                </toolkit:EntryLine>
                <toolkit:EntryLine 
                   Text="{Binding NamespaceUri}" 
                   HorizontalOptions="FillAndExpand"
                   HorizontalTextAlignment="Center"
                   Placeholder="Namespace"
                   StyleId="EmailTextField"
                   Keyboard="Text"
                   BorderColor="#ECECEC">
                    <toolkit:EntryLine.HorizontalTextAlignment>
                        <OnPlatform x:TypeArguments="TextAlignment" iOS="Center"/>
                    </toolkit:EntryLine.HorizontalTextAlignment>
                </toolkit:EntryLine>
            </StackLayout>
            <!--Third Stack Layout-->
            <StackLayout>
                <StackLayout.Padding>
                    <OnPlatform x:TypeArguments="Thickness" Android="32,16,32,0" iOS="32,25,32,0" WinPhone="32,16,32,0"/>
                </StackLayout.Padding>
                <StackLayout.Spacing>
                    <OnPlatform x:TypeArguments="x:Double" Android="0" iOS="16" WinPhone="10"/>
                </StackLayout.Spacing>
                <Button 
                Text="Sign In"
                Command="{Binding LoginCommandSso}"
                HorizontalOptions="FillAndExpand"
                StyleId="SignInButton"
                TextColor="White"
                BackgroundColor="{StaticResource Primary}">
                    <Button.FontAttributes>
                        <OnPlatform x:TypeArguments="FontAttributes" iOS="Bold"/>
                    </Button.FontAttributes>
                </Button>
            </StackLayout>
        </StackLayout>
        <!--StackLayout 2-->
        <!--Contains activity indicator and Corresponding label-->
        <AbsoluteLayout>
            <StackLayout 
        Grid.Row="1" 
        Padding="16,0" 
        VerticalOptions="Center" 
        Orientation="Horizontal"
        HorizontalOptions="Center"
        AbsoluteLayout.LayoutFlags="PositionProportional"
        AbsoluteLayout.LayoutBounds="0.5,0.5,-1,-1"
        IsVisible="{Binding IsBusy}">
                <ActivityIndicator IsRunning="{Binding IsBusy}">
                    <ActivityIndicator.Color>
                        <OnPlatform x:TypeArguments="Color" Android="{StaticResource Primary}"/>
                    </ActivityIndicator.Color>
                </ActivityIndicator>
                <Label Text="{Binding Message}" VerticalOptions="Center"  HorizontalOptions="Center" />
            </StackLayout>
        </AbsoluteLayout>
        <!--Stack Layout 3-->
    </Grid>
</ScrollView>

在Android模拟器上运行时,我可以在"EntryLine"中输入文本,一切似乎都很好。但是,当我尝试在IOS模拟器上运行它时,文本变得不可编辑,即只读。基本上在IOS模拟器上,StackLayout中的所有内容都变成了"只读">我也尝试使用表单"Entry"而不是FormsToolKit.EntryLine,但没有结果。我在上面的代码本身中遇到了一个问题,在 xaml 中添加一个"条目"并在 IOS 模拟器上进行测试工作正常。已经在Xamarin论坛上提出了同样的问题,但没有找到任何答案。

编辑 1 - 添加了完整的堆栈布局。

用-

  • Visual Studio 2017, Windows 10, Xamarin - 2.3.4.247FormsToolKit - 1.1.18 IOS - MacBook Air 10.3

您的<AbsoluteLayout>与您的内容重叠并捕获所有输入事件。您必须尝试将其IsVisible属性设置为 false(或要尝试的InputTransparent属性(。至少只要活动指示器未运行。

(

如果这不起作用,您可以尝试使用专门在iOS上设置输入透明度的效果(或自定义渲染器(来处理它(

(您也可以考虑不将其放置在滚动视图中,因为它最终会被滚动走(

最新更新