iOS 11.1.2上的Xamarin.Forms:Webview加载了更大的字体

Dio*_*uez 5 webview ios xamarin.forms

我正在使用Xamarin.Forms加载互联网的网页(客户端的要求,请不要评判我),问题是在iOS中网页看起来更大.

我在iOS上没有任何自定义渲染.

这是iPhone 6 iOS 11.1.2上的safari上加载的网站

这里加载在webview上

MainPage.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"
             xmlns:local="clr-namespace:Juppie"
             x:Class="Juppie.MainPage">
             <Grid>

    <WebView x:Name="Navegador" Source="http://empleosapp.caonainteractive.com/" 
    WidthRequest="1000" HeightRequest="1000" IsVisible="{Binding Path=HayInternet}" ></WebView>
    <ActivityIndicator IsRunning="{Binding Path=Navegando}" IsVisible="{Binding Path=Navegando}"
        VerticalOptions="CenterAndExpand"
                               HorizontalOptions="CenterAndExpand"
                               RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,
                                        Property=Height,
                                        Factor=0.33}"
                               RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,
                                        Property=Height,
                                        Factor=0.33}"/>
    </Grid>


</ContentPage>
Run Code Online (Sandbox Code Playgroud)

MainPage.xaml.cs中

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Plugin.Connectivity;
using System.ComponentModel;

namespace Juppie
{
    public partial class MainPage : ContentPage, INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        public MainPage()
        {
            InitializeComponent();

            Navegador.Navigating += Navegador_Navigating;
            Navegador.Navigated += (sender, e) => { Navegando = false; };
            HayInternet = true;
            BindingContext = this;
        }
        bool hayInternet;

        public bool HayInternet
        {
            get
            {
                return hayInternet;
            }

            set
            {
                hayInternet = value;

                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("HayInternet"));

                EvaluarInternet();
            }
        }
        bool navegando;

        public bool Navegando
        {
            get
            {
                return navegando;
            }

            set
            {
                navegando = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Navegando"));

            }
        }

        public async void EvaluarInternet(){
            if (!HayInternet)
            {
             await DisplayAlert("Aviso","Se requiere conexion a internet para emplear esta aplicacion", "OK");
            }
        }

        protected override void OnAppearing()
        {
            HayInternet = CrossConnectivity.IsSupported && CrossConnectivity.Current.IsConnected;

            CrossConnectivity.Current.ConnectivityChanged += (sender, args) =>
            {
                HayInternet = args.IsConnected;
            };

            base.OnAppearing();
        }

        protected override bool OnBackButtonPressed()
        {
            if (Navegador.CanGoBack)
            {
                Navegador.GoBack();
                return false;
            }

            return base.OnBackButtonPressed();
        }

        void Navegador_Navigating(object sender, WebNavigatingEventArgs e)
        {
            Navegando = true;
            if (e.Url.Contains("/banner"))
            {
                e.Cancel = true;

                var uri = new Uri(e.Url.Replace("/banner", ""));
                Device.OpenUri(uri);
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我尝试使用自定义渲染并设置scalePageToFit = false,但没有成功.如果有人知道我该如何解决这个问题,请告诉我.

Jas*_*son 2

在我的 iPhone 6 上进行测试,该应用程序显示的字体大小与 Safari 相同。我还在应用程序中的字体大小中使用较大的系统字体进行了测试,并且它不受应用程序字体大小的影响。但我确实注意到,当活动指示器运行时,我的字体变小,活动指示器消失后又恢复正常。

也许字体大小问题是由 Nuget 包或活动指示器等任何附加内容的副作用引起的?

您可以尝试使用新的空表单并仅加载 Webview 来比较差异。

顺便说一句,您的应用程序外观与打开“显示缩放”功能的 iPhone 非常相似。

打开显示缩放之前:

在此输入图像描述

开启显示缩放后:

在此输入图像描述