我正在使用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,Factor=0.33}"/> </Grid> </ContentPage>
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); } } } }
我尝试使用自定义渲染并设置scalePagetoFit = false,但没有成功.
如果有人知道我该如何解决这个问题,请告诉我.
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。