iOS平台Xamarin Editor控件干扰其他控件问题求助
iOS平台下Xamarin.Forms Editor多行展开导致下方控件无法访问的问题
- Editor设置
AutoSize="TextChanges",随输入自动展开,无字符长度限制,支持用户输入超100字符。 - 仅iOS平台存在异常:当Editor输入满2行(约42字符)后,输入第3行首个字符(第45字符)时,下方的
entInitialsEntry控件无法获取焦点;退回到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
相关产品推荐
相关产品推荐

