maui-ios 相关问题


如何在MAUI iOS中使用1x、2x和3x .png图像?

我知道我们必须使用 .svg 图像格式而不是 1x,2x,3x .png 图像格式,MAUI 会处理它,但我目前正在将现有的 Xamarin Forms 应用程序迁移到 MAUI,并且很难转换.. .


如何在 iOS 上的 .NET MAUI 中增加 TabBar 菜单项的字体大小?

我正在使用 .NET MAUI Shell Tabbar,并且我正在尝试专门在 iOS 平台上增加 TabBar 菜单项的字体大小。您能否为此提供示例代码片段? 我很感激任何


无法构建或发布应用程序 maui,有很多错误

我的应用程序在启动时在 IOS 和 Android 上运行良好,但是当我尝试在 Android 上发布应用程序时,我收到所有这些错误: android 应用程序 .net maui 1>C:\Program Files\Microsoft Visual Studio�2\


无法在 Azure DevOps 中使用 Visual Studio 17.8.3 包发布 .Net Maui Asp.Net 7 或 8 iOS 应用程序

我的应用程序过去使用 Azure DevOps 发布得很好,当时它是一个面向 iOS 16.1 且支持 15.4 框架的 ASP.net 7 应用程序。我使用的是 Visual Studio Enterprise 2022 17.5.3 包。 我...


无法在 Azure DevOps 中使用 Visual Studio 17.8.3 包发布面向 iOS 的 ASP.NET 7 或 8 Maui 应用程序

我的应用程序过去使用 Azure DevOps 发布得很好,当时它是一个面向 iOS 16.1 并具有 15.4 支持框架的 ASP.NET 7 应用程序。我使用的是 Visual Studio Enterprise 2022 17.5.3 包。 我...


如何在运行时向IntentFilter添加值

我有一个使用 MSAL 登录的 maui 应用程序,我可以在 android 和 ios 上登录。但我想在运行时将值分配给 DataScheme。我们正在管道中绑定这些值并采取...


.NET Maui 条目已完成,iOS 上没有返回按钮?

我正在使用输入控件(.Net 7),键盘类型专门设置为数字,因为不需要输入字母文本,并且会导致问题,因为它将数据发送到 BT 设备并且是


.NET MAUI、ios UseSafeArea 不工作 StackLayout、VerticalStackLayout 和 Grid

<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Test.Views.Activities.ActivityMapList" xmlns:maps="clr-namespace:Microsoft.Maui.Controls.Maps;assembly=Microsoft.Maui.Controls.Maps" xmlns:sensors="clr-namespace:Microsoft.Maui.Devices.Sensors;assembly=Microsoft.Maui.Essentials" xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls" ios:Page.UseSafeArea="False" Shell.NavBarIsVisible="False" Style="{StaticResource Key=DefaultPage}"> <ContentPage.Content> <StackLayout> <maps:Map VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"> <x:Arguments> <MapSpan> <x:Arguments> <sensors:Location> <x:Arguments> <x:Double>36.9628066</x:Double> <x:Double>-122.0194722</x:Double> </x:Arguments> </sensors:Location> <x:Double>0.01</x:Double> <x:Double>0.01</x:Double> </x:Arguments> </MapSpan> </x:Arguments> </maps:Map> </StackLayout> </ContentPage.Content> </ContentPage> StackLayout 或 Grid 内的地图控件,iOS 的 SafeArea 为 false,如图所示。 你有什么解决办法吗? 我需要在地图上使用网格或堆栈布局 默认情况下.NET MAUI 将考虑安全区域。所以使用特定于平台的UseSafeArea就是禁用安全区域。目前,将 UseSafeArea 设置为 false 不会改变行为(尽管应该如此),这是一个错误。另请参阅 MAUI github 上的问题:https://github.com/dotnet/maui/issues/5856 您还可以设置 IgnoreSafeArea 属性来实现相同的目的。但是,它不再在 .NET 7 中工作,请参阅以下问题:https://github.com/dotnet/maui/issues/12823 要解决您的问题,您需要将 IgnoreSafeArea="True" 添加到您的 Grid 或 StackLayout 并将 ios:Page.UseSafeArea="False" 添加到您的页面。这应该不是必需的,但这是对我有用的解决方法。 有关在 iOS 上禁用安全区域的文档可以在此处找到:https://learn.microsoft.com/en-us/dotnet/maui/ios/platform-specifics/page-safe-area-layout?view=net-毛伊岛-7.0 您可以设置 Page Padding 值来实现。在OnAppearing方法中,设置页面的safeInsets,如下代码: protected override void OnAppearing() { base.OnAppearing(); DeviceSafeInsetsService d = new DeviceSafeInsetsService(); double topArea = d.GetSafeAreaTop(); double bottomArea = d.GetSafeAreaBottom(); var safeInsets = On<iOS>().SafeAreaInsets(); safeInsets.Top = -topArea; safeInsets.Bottom = -bottomArea; Padding = safeInsets; } 要获取 topArea 和 bottomArea 值,您应该编写平台代码。答案末尾附有有关此内容的更详细教程。 首先你可以在Project文件夹中生成一个新的类文件并将其更改为部分类。生成两个部分方法。 public partial class DeviceSafeInsetsService { public partial double GetSafeAreaTop(); public partial double GetSafeAreaBottom(); } 然后在iOS平台生成部分文件并实现。该文件位于 Project/Platform/iOS 文件夹中,我想提一下的是,该文件是一个部分文件,因此命名空间应与上面的文件相同。生成此文件时,请删除命名空间中的 .Platforms.iOS 后缀。 public partial class DeviceSafeInsetsService { public partial double GetSafeAreaBottom() { if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) { UIWindow window = UIApplication.SharedApplication.Delegate.GetWindow(); var bottomPadding = window.SafeAreaInsets.Bottom; return bottomPadding; } return 0; } public partial double GetSafeAreaTop() { if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) { UIWindow window = UIApplication.SharedApplication.Delegate.GetWindow(); var TopPadding = window.SafeAreaInsets.Top; return TopPadding; } return 0; } } 更多信息,您可以参考如何在.NET MAUI中编写特定于平台的代码和MauiPlatformCode示例代码 希望它对你有用。


Microsoft MAUI:如何在 MAUI 中创建在新窗口中打开的报告?

如何在 MAUI 中创建在新窗口中打开的动态报告?


识别.NET MAUI 应用程序中用户所在的页面

如何在 .NET MAUI shell 应用程序中识别用户所在的页面? 为了提供更多背景信息,这就是我正在尝试做的事情: 我的 .NET MAUI 应用程序(使用 Shell)有相当多的页面,其中一些...


iOS 推送通知内容中的图像

如何在ios推送通知内容中添加图标图片


Foursquare iOS API

我试图弄清楚如何修改此处找到的 Foursquare iOS API“BZFoursquare”:https://github.com/baztokyo/foursquare-ios-api。 在他们的示例中,他们使用一体化 ViewContro...


.NET MAUI - 为什么推送通知在发布后无法正常工作?

因此,我有一个专门针对 Android 的 .NET MAUI 移动应用程序,它已使用 Intent 过滤器通过 OnMessageReceived() 方法和 OnNewToken() 实现了推送通知,并...


MAUI WebView 控件和 CORS

尝试使用 WebView 控件编写 MAUI 应用程序,以便我可以教学生如何解决复杂的数学问题。我选择使用 MathML,因为它支持大多数数学符号以包含自动调整...


MAUI 中切换风格问题

我正在我的 MAUI 项目上使用开关。我在 Android 设备 10 和 11 上发现了样式问题,但在 Android 12 上,不存在样式问题。 以下是 Android 10 和 Android 11 的屏幕截图。 贝尔...


Control Maps Net Maui (net 8.0) for Windows

我正在使用 net 8.0,我想使用 Maui.Controls.Map。 MauiProgram.cs 中的代码是: 公共静态 MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuild...


如何获取应用程序的屏幕空间或 MAUI 中顶部和底部栏的高度?

我在计算某些项目的位置时遇到问题,以及它们是否在 MAUI 的屏幕上可见,使用如下函数 public Point GetScreenCoords(VisualElement视图) { var 结果 = 新...


.NET MAUI:自定义Shell TitleView并绑定到当前页面标题

我想用我自己的自定义布局替换默认的 Shell 标头,如下所示: 我想用我自己的自定义布局替换默认的 Shell 标头,如下所示: <?xml version="1.0" encoding="UTF-8" ?> <Shell x:Class="MyNamespace.App.AppShell" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:MyNamespace.App" xmlns:pages="clr-namespace:MyNamespace.App.Pages" BindingContext="{x:Static local:MainView.Instance}" Shell.FlyoutBehavior="{Binding ShellFlyoutType}" x:Name="shellMain"> <Shell.TitleView> <Grid ColumnDefinitions="*,200"> <Label BindingContext="{x:Reference shellMain}" Text="{Binding Path=CurrentPage.Title, Mode=OneWay}" FontSize="Large" TextColor="White" /> <ActivityIndicator IsRunning="{Binding IsBusy}" Color="Orange" Grid.Column="1" HorizontalOptions="End" /> </Grid> </Shell.TitleView> <ShellContent Title=" Login" ContentTemplate="{DataTemplate local:MainPage}" Route="login" FlyoutItemIsVisible="False" /> <ShellContent Title="Dashboard" ContentTemplate="{DataTemplate pages:DashboardPage}" Route="dashboard" /> </Shell> 我无法绑定当前页面标题。 我的 AppShell.xaml Shell 声明如下 <Shell ... x:Name="shellMain"> 作为替代方案,您可以在 OnNaviged 方法中设置 titleview : 在 AppShell.xaml 中,定义标签的名称 <Shell.TitleView> <Grid ColumnDefinitions="*,200"> <Label BindingContext="{x:Reference shellMain}" x:Name="mylabel" FontSize="Large" TextColor="White" /> <ActivityIndicator IsRunning="{Binding IsBusy}" Color="Orange" Grid.Column="1" HorizontalOptions="End" /> </Grid> </Shell.TitleView> 在AppShell.xaml.cs中,重写OnNaviged方法,获取当前项目 protected override void OnNavigated(ShellNavigatedEventArgs args) { base.OnNavigated(args); var shellItem = Shell.Current?.CurrentItem; string title = shellItem?.Title; int iterationCount = 0; while (shellItem != null && title == null) { title = shellItem.Title; shellItem = shellItem.CurrentItem; if (iterationCount > 10) break; // max nesting reached iterationCount++; } myLabel.Text = title; } 希望它对你有用。 我正在尝试同样的方法来修改 TitleView 的外观。它可以在 iOS 上运行,尽管那里还有另一个错误。但在 Android 上我遇到了同样的问题。在前进导航中,它会更新标题,但当您按后退按钮时,标题不会更新。我已经打开了一个问题并添加了一个存储库。 https://github.com/dotnet/maui/issues/12416#issuecomment-1372627514 还有其他方法可以修改TitleView的外观吗? 我使用视图模型开发了这个解决方法,主要不是为了提供 MVVM 解决方案,而是因为其他建议的答案对我不起作用。 (我怀疑 Liqun Shen 2 月 15 日针对他自己的问题的评论中的建议会起作用。但我没有注意到这一点,直到我自己修复)。 当前页面的标题保存在可由 shell 的视图模型和每个内容页面的视图模型访问的类中: public class ServiceHelper { private static ServiceHelper? _default; public static ServiceHelper Default => _default ??= new ServiceHelper(); internal string CurrentPageTitle { get; set; } = string.Empty; } shell 中每个内容页面的视图模型提供其页面标题。为了促进这一点,大部分工作都是由基本视图模型完成的,它们都是从该模型派生而来的: public abstract class ViewModelBase(string title) : ObservableObject { private ServiceHelper? _serviceHelper; public string Title { get; } = title; internal ServiceHelper ServiceHelper { get => _serviceHelper ??= ServiceHelper.Default; set => _serviceHelper = value; // For unit testing. } public virtual void OnAppearing() { ServiceHelper.CurrentPageTitle = Title; } } 每个 shell 内容页面视图模型只需要让其基础视图模型知道它的标题: public class LocationsViewModel : ViewModelBase { public LocationsViewModel() : base("Locations") { } } 每个 shell 内容页面都需要在其视图模型中触发所需的事件响应方法: public partial class LocationsPage : ContentPage { private LocationsViewModel? _viewModel; public LocationsPage() { InitializeComponent(); } private LocationsViewModel ViewModel => _viewModel ??= (LocationsViewModel)BindingContext; protected override void OnAppearing() { base.OnAppearing(); ViewModel.OnAppearing(); } } Shell 的视图模型为标题栏提供当前页面的标题: public class AppShellViewModel() : ViewModelBase(Global.ApplicationTitle) { private string _currentPageTitle = string.Empty; public string CurrentPageTitle { get => _currentPageTitle; set { _currentPageTitle = value; OnPropertyChanged(); } } public void OnNavigated() { CurrentPageTitle = ServiceHelper.CurrentPageTitle; } } Shell 需要在其视图模型中触发所需的事件响应方法: public partial class AppShell : Shell { private AppShellViewModel? _viewModel; public AppShell() { InitializeComponent(); } private AppShellViewModel ViewModel => _viewModel ??= (AppShellViewModel)BindingContext; protected override void OnNavigated(ShellNavigatedEventArgs args) { base.OnNavigated(args); ViewModel.OnNavigated(); } } 最后,Shell 的 XAML 在标题栏/导航栏上显示由 Shell 视图模型提供的当前页面的标题: <Shell.TitleView> <HorizontalStackLayout VerticalOptions="Fill"> <Image Source="falcon_svg_repo_com.png" HeightRequest="50"/> <Label x:Name="CurrentPageTitleLabel" Text="{Binding CurrentPageTitle}" FontSize="24" Margin="10,0" VerticalTextAlignment="Center"/> </HorizontalStackLayout> </Shell.TitleView>


MAUI 8 - 如何更改弹出背景叠加颜色?

使用 MAUI 7.0,下一个代码允许更改弹出背景叠加颜色,但该代码不适用于 MAUI 8.0 使用 MAUI 7.0,下一个代码允许更改弹出窗口背景覆盖颜色,但该代码不适用于 MAUI 8.0 <maui:MauiWinUIApplication x:Class="TestMaui8.WinUI.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:maui="using:Microsoft.Maui" xmlns:local="using:TestMaui8.WinUI"> <maui:MauiWinUIApplication.Resources> <Color x:Key="SystemAltMediumColor">Transparent</Color> <SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="{StaticResource SystemAltMediumColor}" /> <SolidColorBrush x:Key="ContentDialogBackgroundThemeBrush" Color="{StaticResource SystemAltMediumColor}" /> <SolidColorBrush x:Key="ContentDialogDimmingThemeBrush" Color="{StaticResource SystemAltMediumColor}" /> <StaticResource x:Key="ContentDialogBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" /> <StaticResource x:Key="PopupLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" /> <SolidColorBrush x:Key="SliderBorderBrush" Color="#1A73E8" /> <Style TargetType="Slider"> <Setter Property="BorderBrush" Value="{StaticResource SliderBorderBrush}"/> </Style> </maui:MauiWinUIApplication.Resources> </maui:MauiWinUIApplication> 有人知道为什么它不起作用以及如何修复它吗? 更新添加一些图片 CommunityToolkit Popup 没有 Overlay color 功能。您可以在 CommunityToolkit GitHub 页面上提出功能请求。 是的,您发布的上述代码曾经可以工作,但它不适用于具有最新 CommunityToolkit.Maui nuget 的 .NET8。 但是如果您想更改叠加颜色,这里有一个解决方法。 <toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui" ... Color="Black" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" > //make the size to be the full screen size <ContentView WidthRequest="1920" HeightRequest="1080"> <VerticalStackLayout WidthRequest="300" HeightRequest="300" BackgroundColor="Green"> <Image Source="dotnet_bot.png"/> <Label Text="Welcome to .NET MAUI!" VerticalOptions="Center" HorizontalOptions="Center" /> </VerticalStackLayout> </ContentView> </toolkit:Popup>


无法在iOS模拟器中运行应用程序

问题: \[!\] CocoaPods 找不到 pod“libphonenumber_plugin”的兼容版本: 在 Podfile 中: libphonenumber_plugin(来自 \`.symlinks/plugins/libphonenumber_plugin/ios\`) ...


如何在.Net MAUI 中访问麦克风输入?

我正在开发 .net maui 应用程序,该应用程序可以测量音量并通过蓝牙将其发送到记录数据并制作图表的电脑,作为一个业余爱好项目。我的问题是访问麦克风输入。好像有...


iOS 中的屏幕时间报告[已关闭]

如何在我的 iOS 应用程序中获取包含 iOS 12 屏幕时间中显示的信息的报告?有API或者有人知道如何获取这些信息吗?


MAUI 应用程序在目标升级到 .NET8 后运行模拟器之前抛出错误

我有一个相当简单的.NET MAUI 应用程序,我正在 Win10 上的 Visual Studio 中开发它,然后通过在模拟器中运行它来测试它。它工作得很好,直到我将目标框架从 .NET7 升级到...


如何在 MAUI 中重置所有 DI 服务或用户注销时的 DI 范围?

在我的 MAUI Blazor 应用程序中,用户可以在运行时注销。当他们这样做时,我基本上想重置所有注入的服务,因此当另一个用户登录时,他们会获得“新鲜”状态,避免可能的情况


在 .NET MAUI ContentView 中充当可绑定属性

ContentView 中的 Bindable 属性可以是 Func 类型吗?也就是说,像这样: 公共部分类 MyControl :ContentView { 公共静态只读 BindableProperty


MAUI:如何在代码中绑定事件属性(sender、EventArgs);绑定到 ViewModel 或代码隐藏

我已使用 XAML 标记成功将 DrogGestureRecognizer 的 Drop 事件绑定到 CodeBehind,如下所示: ...


列出 iOS 16 破坏的行分隔线

我有一个节标题列表,每个节标题有 1 行或多行。 自从更新到 iOS 16 以来,行分隔线已被推到右侧(如第一个屏幕截图所示)。 在 iOS 15.7 上运行时,该行


你能收到iOS模拟器的FCM推送通知吗?

我最近开始了 iOS 开发,并尝试使用 Firebase 构建一个具有推送通知功能的简单的基于 Web 的 iOS 应用程序。 我已经尝试了大约 3 个关于发送推送的教程


React Native iOS - 模态未在模拟器上显示

如标题所示,该模式未在 iOS 模拟器和生成的 IPA 文件上显示。但在 Android 模拟器上运行良好。我是否错过了任何特定于 iOS 的代码?被这个问题困扰了一段时间。


Xamarin Forms 或 .NET Maui 中 RevenueCat 应用内功能的示例代码?

我在这里发布一些示例代码,因为在使用 RevenueCat 开发 Xamarin Forms 应用程序时找不到任何示例代码。


需要隐私清单blinkid-iOS

在 WWDC23 上,Apple 宣布使用某些“必要原因”API 等的应用程序和 SDK 需要提供隐私清单。 Blinkid-iOS 是否需要包含此清单? 我...


通过底部表单中的参数过滤.NET MAUI MVVM中collectionView的数据

我正在过滤一个从 ObservableCollection 获取数据的 collectionView。逻辑位于 ViewModel 类中。我从 HTTP 请求获取 ObservableCollection 的数据,之后...


将 Xamarin UWP 应用程序升级到毛伊岛后,新更新拒绝安装

这几乎正是我所发生的事情:https://learn.microsoft.com/en-us/answers/questions/1000760/migrate-uwp-app-to-maui-windows-error-after-更新?评论=问题#最新问题-


如何访问私有iOS API? [已关闭]

我想从iOS SDK访问一些与相机相关的私有API,例如: - (void)setExposureMode:(int)arg1; - (int)曝光模式; 等等。这只是为了我个人的发展,我...


NET8 MAUI ListView 选择项目为橙色

我过去问过这个问题,得到的答案是这是一个错误,它将在 NET8 中修复。 使用新版本的框架,问题仍然存在。当我跑步时...


SoundCloud iOS 启动教程 - 无法识别的选择器

我正在遵循 iOS 快速入门教程,并且已经创建了登录 SoundCloud 的按钮,但我收到此错误: 2013-05-01 15:00:44.698 SoundCloudSample[60999:c07] +[


我们可以在跨平台使用android/ios sdk吗,比如react native/flutter/ionic

mapmyindia(mmi) 提供适用于 Android 和 ios 的地图 sdks 以及适用于 Web 的地图 api SDK 可以免费使用,但 API 不能免费使用 但是混合动力呢 我可以在 ionic/flut 中使用 mmi(不是 api)的 android 或 ios sdks...


为什么 EFCore 6 不再在 iOS 上运行?

我在使用 .net6 构建的 iOS 应用程序上使用 Entity Framework Core 6。它曾经适用于旧版本(EF 和 .net),但现在我收到以下错误: 系统。


带有操作按钮的本地通知

我从 iOS 上的 flutter 本地通知下载并运行了示例,但在 iOS 上看不到任何操作按钮,我没有在 Android 上尝试。我需要能够小睡


使用 MKCreateClusterAnnotation Xamarin Forms 显示集群视图

如何使用 ios 地图渲染对 pin 结果进行分组或聚类? 我尝试了以下逻辑,但我在实现中感到困惑。 https://github.com/xamarin/ios-samples/blob/main/ios11/MapKitS...


无法在ios上打开sqlite db

嗨,我正在尝试在 ios 中创建一个 sqlite 数据库。 我使用 sqlite3_open 方法以及所需的参数,但总是收到错误 14 (SQLITE_CANTOPEN 14 /* 无法打开数据库文件 */...


maui android 应用程序在管道中构建失败,并出现错误“找不到 Android SDK 目录”

如果没有任何代码更改,Android 的管道构建将失败并出现以下错误。 /opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/33.0.95/tools/Xamarin.Android.Tooling.targets(70...


Maui Blazor 按钮点击导航

我有一个带有按钮的页面,该按钮调用异步 webapi,然后导航到另一个页面。然而,尽管代码运行没有错误,但它不会转到新页面。相反,当前...


在Maui注册兼容性PageRenderer导致堆栈溢出异常

我正在尝试重用 Xamarin.Forms 中的现有 PageRenderer 项目,以其迁移的应用程序形式。 当页面开始加载时,出现堆栈溢出异常: Java.Interop.NativeMet 中的 0x39...


.NET MAUI TabBar 登录/注销问题

我遇到一个问题,当用户导航到“设置”选项卡并单击注销选项时,该选项会将用户导航回登录屏幕,但当用户重新登录选项卡栏时,


在flutter项目中添加风味后,AppCilrcle平台上的iOS构建失败

我已经只为单个环境构建了setps,但现在我正在尝试为多个环境(prod、dev)构建iOS应用程序。为此,我已在


棱镜:ViewModelLocator.AutowireViewModel 不适用于内容视图

我正在将使用 Prism 的 Xamarin.Forms 应用程序迁移到 .NET Maui。该应用程序有一个 TabbedPage 导航。此迁移有效。 但是 ContentPages 包含几个 ContentView,如下所示: 我正在将使用 Prism 的 Xamarin.Forms 应用程序迁移到 .NET Maui。该应用程序有一个 TabbedPage 导航。此迁移有效。 但是 ContentPages 包含几个 ContentView,如下所示: <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:views="clr-namespace:MauiDemo.Views" x:Class="MauiDemo.Views.HomePage" Title="HomePage"> <VerticalStackLayout> <views:FirstContentView HeightRequest="200"/> <views:SecondContentView HeightRequest="200"/> </VerticalStackLayout> </ContentPage> 在 Xamarin 中,我能够将 prism:ViewModelLocator.Autowire="true" 属性添加到 contentview 中,并且 prism 找到了关联的视图模型。在 .NET maui 中,prism:ViewModelLocator.AutowireViewModel="Automatic" 属性没有任何作用。 例如,ContentView 的名称是 “FirstContentView”。关联的viewModel的名称是“FirstContentViewViewModel” 根据https://prismlibrary.com/docs/maui/migration.html中的描述,它应该可以工作,但事实并非如此。 配置这样的自动接线有什么技巧吗? 我使用 prism 存储库的当前克隆 https://github.com/PrismLibrary/Prism 以及带有最新 MAUI 组件的当前 .NET8 SDK 我使用区域而不是通过自动装配。具有不同 ContentView 的页面应该如下所示 <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:views="clr-namespace:MauiDemo.Views" xmlns:prism="http://prismlibrary.com" x:Class="MauiDemo.Views.HomePage" Title="HomePage"> <VerticalStackLayout> <ContentView prism:RegionManager.RegionName="FirstContent"/> <ContentView prism:RegionManager.RegionName="SecondContent"/> </VerticalStackLayout> </ContentPage> 所需的视图及其视图模型应在 MauiProgram 中注册为 RegisterForRegionNavigation container.RegisterForRegionNavigation<FirstContentView, FirstContentViewViewModel>(); container.RegisterForRegionNavigation<SecondContentView, SecondContentViewModel>(); .UsePrism(prism => { prism.RegisterTypes(container => { container.RegisterForNavigation<MainPage,MainPageViewModel>(); container.RegisterForNavigation<HomePage>(); container.RegisterForRegionNavigation<FirstContentView, FirstContentViewViewModel>(); container.RegisterForRegionNavigation<SecondContentView, SecondContentViewModel>(); }) .CreateWindow(navigationService => navigationService.CreateBuilder() .AddSegment<MainPage>() .NavigateAsync(HandleNavigationError)); }) 包含多个ContentView的页面的ViewModel应该为所需的ContentView调用RegionManager.RequestNavigate方法。 public class HomePageViewModel : ViewModelBase, IInitialize { private readonly IRegionManager _regionManager; public HomePageViewModel(IRegionManager regionManager) { _regionManager = regionManager; } public void Initialize(INavigationParameters parameters) { _regionManager.RequestNavigate("FirstContent", nameof(FirstContentView)); _regionManager.RequestNavigate("SecondContent", nameof(SecondContentView)); } } 仅此而已。它的工作原理如https://xamgirl.com/prism-regions-in-xamarin-forms/所述


Flutter webview iOS 错误“targetPlatform.macOS 的默认 webview 实现,但没有”

我是 Flutter 新手,我尝试了 Flutter 的 webview,它在 Android 上运行良好 我试图检查 iOS 版本,结果发现 我在用 webview_flutter:^3.0.0 这是我的代码 导入'包:


未找到 ReactNativePermissions pod 规范

所以我尝试运行一个用react-native编写的iOS应用程序项目,在克隆和npm安装之后,我在尝试在iOS文件夹中安装pod时遇到了问题。 这是错误: [!] 不


无法在 Kotlin Multiplatform 中导入 os.log

我正在尝试实现 kotlin 多平台记录器。在iOS架构的实现过程中,我无法导入os.log来使用os_log。我该怎么做或者我还可以使用什么来登录 iOS


© www.soinside.com 2019 - 2024. All rights reserved.