jjzjj

c# - Xamarin Forms IOS "Entry"不可编辑

coder 2023-09-29 原文

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

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

使用 -

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

最佳答案

你的 <AbsoluteLayout>重叠您的内容并捕获所有输入事件。您必须尝试设置其 IsVisible属性为 false(或尝试使用 InputTransparent 属性)。至少只要 Activity 指示器没有运行。

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

(你也可以考虑不把它放在 ScrollView 中,因为它最终会被滚动掉)

关于c# - Xamarin Forms IOS "Entry"不可编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44536942/

有关c# - Xamarin Forms IOS "Entry"不可编辑的更多相关文章

  1. ruby-on-rails - rails : "missing partial" when calling 'render' in RSpec test - 2

    我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou

  2. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  3. ruby-on-rails - Rails 编辑表单不显示嵌套项 - 2

    我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib

  4. ruby - 检查 "command"的输出应该包含 NilClass 的意外崩溃 - 2

    为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar

  5. ruby-on-rails - 迷你测试错误 : "NameError: uninitialized constant" - 2

    我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test

  6. ruby-on-rails - 相关表上的范围为 "WHERE ... LIKE" - 2

    我正在尝试从Postgresql表(table1)中获取数据,该表由另一个相关表(property)的字段(table2)过滤。在纯SQL中,我会这样编写查询:SELECT*FROMtable1JOINtable2USING(table2_id)WHEREtable2.propertyLIKE'query%'这工作正常:scope:my_scope,->(query){includes(:table2).where("table2.property":query)}但我真正需要的是使用LIKE运算符进行过滤,而不是严格相等。然而,这是行不通的:scope:my_scope,->(que

  7. 使用 ACL 调用 upload_file 时出现 Ruby S3 "Access Denied"错误 - 2

    我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file

  8. ruby - 安装 Ruby 时遇到问题(无法下载资源 "readline--patch") - 2

    当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub

  9. c# - 如何在 ruby​​ 中调用 C# dll? - 2

    如何在ruby​​中调用C#dll? 最佳答案 我能想到几种可能性:为您的DLL编写(或找人编写)一个COM包装器,如果它还没有,则使用Ruby的WIN32OLE库来调用它;看看RubyCLR,其中一位作者是JohnLam,他继续在Microsoft从事IronRuby方面的工作。(估计不会再维护了,可能不支持.Net2.0以上的版本);正如其他地方已经提到的,看看使用IronRuby,如果这是您的技术选择。有一个主题是here.请注意,最后一篇文章实际上来自JohnLam(看起来像是2009年3月),他似乎很自在地断言RubyCL

  10. C# 到 Ruby sha1 base64 编码 - 2

    我正在尝试在Ruby中复制Convert.ToBase64String()行为。这是我的C#代码:varsha1=newSHA1CryptoServiceProvider();varpasswordBytes=Encoding.UTF8.GetBytes("password");varpasswordHash=sha1.ComputeHash(passwordBytes);returnConvert.ToBase64String(passwordHash);//returns"W6ph5Mm5Pz8GgiULbPgzG37mj9g="当我在Ruby中尝试同样的事情时,我得到了相同sha

随机推荐