You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iOS平台Xamarin Editor控件干扰其他控件问题求助

iOS平台下Xamarin.Forms Editor多行展开导致下方控件无法访问的问题
  • Editor设置AutoSize="TextChanges",随输入自动展开,无字符长度限制,支持用户输入超100字符。
  • 仅iOS平台存在异常:当Editor输入满2行(约42字符)后,输入第3行首个字符(第45字符)时,下方的entInitials Entry控件无法获取焦点;退回到2行文本时,控件恢复可访问状态。
  • 最初布局是将每个控件(标签和输入控件)放在各自ViewCell的Grid中,但Editor展开时会覆盖下方ViewCell内的控件。
  • 尝试将Editor和Entry放入同一ViewCell的Grid中,视觉上Editor展开会将Entry向下推送,但Entry仍无法被正常访问。
  • 额外问题:若Editor展开行数过多,其下方的任何容器(Table Section、ViewCell等)都会被覆盖或无法访问;Android平台无此问题,展开的Editor/ViewCell会自动向下推送下方ViewCell。

表单布局代码

<ScrollView>
    <TableView Intent="Data" HasUnevenRows="true" Margin="10,0,10,0">
        <TableRoot>
            <TableSection>
                <ViewCell>
                    <StackLayout Orientation="Horizontal">
                        <Label Text="{Binding Source={x:Static sys:DateTime.Now}, StringFormat='{0:MMMM d, yyyy HH:mm}'}" Style="{StaticResource LabelDate}" />
                    </StackLayout>
                </ViewCell>
                <ViewCell>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="30"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="5"/>
                            <RowDefinition Height="40"/>
                        </Grid.RowDefinitions>
                        <Label Text="Instructions" Style="{StaticResource LabelEntry}"/>
                        <Editor x:Name="fcInstructions" Placeholder="Instructions" Focused="EditorHighlight" Unfocused="EditorHighlight" 
                                Style="{StaticResource EditorMessage}" />

                        <StackLayout x:Name="stkInit" BackgroundColor="White" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2"
                                     Orientation="Horizontal">
                            <Label x:Name="lblInits" Text="User Initials:" Style="{StaticResource LabelEntry}"/>
                            <Entry x:Name="entInitials" Focused="EntryHighlightInit" Unfocused="EntryHighlightInit" 
                                   Style="{StaticResource EntryInitials}"/>                                       
                        </StackLayout>
                    </Grid>
                </ViewCell>

Editor全局样式代码

<Style x:Key="EditorMessage" TargetType="Editor">
    <Setter Property="Grid.Column" Value="0"/>
    <Setter Property="Grid.Row" Value="1"/>
    <Setter Property="Grid.ColumnSpan" Value="2"/>
    <Setter Property="AutoSize" Value="TextChanges"/>
    <Setter Property="Keyboard" Value="Default"/>
    <Setter Property="Placeholder" Value="Message"/>
    <Setter Property="BackgroundColor" Value="Transparent"/>
    <Setter Property="TextColor" Value="Black"/>
    <Setter Property="local:KeyboardStyle.KeyboardFlags"
            Value="Suggestions,CapitalizeCharacter"/>
</Style>

内容的提问来源于stack exchange,提问作者Gary H

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 07:34:54