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

MAUI iOS调试时WebView显示空白问题求助

iOS调试时MAUI WebView空白,部署后正常的问题排查

问题说明

调试MAUI应用时,iOS端WebView显示空白,但部署应用后WebView可正常渲染,Windows端调试无异常。最终需获取页面重定向后的Cookie,需先解决页面渲染问题。本人不熟悉iOS开发,以下是相关配置代码:

XAML代码

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="FreshMaui.Pages.LoginPage"
         Title="LoginPage">
<Grid ColumnDefinitions="*" RowDefinitions="*" WidthRequest="500" HeightRequest="1500">
    <WebView x:Name="WebView"
             Grid.Column="0"
             Grid.Row="0"
     MinimumHeightRequest="1000"
     MinimumWidthRequest="200" 
     VerticalOptions="FillAndExpand" 
     HorizontalOptions="FillAndExpand" Navigated="WebView_Navigated"/>
</Grid>

后台代码(Xaml.cs)

public LoginPage()
{
    Shell.SetNavBarIsVisible(this, false);
    InitializeComponent();
    WebView.IsVisible = true;
    WebView.Source = "https://[website].com/login.aspx?WL_Type=I&WL_AppId=[appid]&WL_ReturnMethod=FV&WL_Expire=1&ReturnMethod=Get&WL_ReturnUrl=[appurl]://FreshMaui/Pages/LoginPage.xaml?p1=v1";
}

补充信息

在Safari中访问该URL时会提示SSL证书不受信任,以下是info.plist配置:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UIDeviceFamily</key>
    <array>
        <integer>1</integer>
        <integer>2</integer>
    </array>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>arm64</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>CFBundleDisplayName</key>
    <string>[App Name]</string>
    <key>CFBundleIdentifier</key>
    <string>[AppId]</string>
    <key>CFBundleVersion</key>
    <string>24000</string>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>XSAppIconAssets</key>
    <string>Assets.xcassets/icon44_ios_g.appiconset</string>
    <key>UIBackgroundModes</key>
    <array>
        <string>fetch</string>
    </array>
  <key>NSAppTransportSecurity</key>
        <dict>
      <key>NSAllowsArbitraryLoadsInWebContent</key>
      <true/>
    </dict>
  
</dict>
</plist>

内容的提问来源于stack exchange,提问作者Zack Watson

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.26 08:31:12