xamarin 相关问题

Xamarin是一个由Xamarin.iOS,Xamarin.Android,Xamarin.Mac和Xamarin Test Cloud组成的平台。它允许您编写适用于iOS,Android和Mac的跨平台本机应用程序,并在整个生命周期内关注您的应用程序。 Xamarin.Forms的引入支持iOS,Android和Windows的Native UI开发

Azure DevOps Android 发布到 Google Play 商店失败

我是 CI/CD 新手。我不明白我做错了什么。 我在 Azure Devops 中设置了一个管道,用于签署 aab 文件并将其放入 Artifacts 中。到目前为止,一切都很好。 然后我创建了一个版本

回答 1 投票 0

Xamarin.Android 应用程序中的深度链接不起作用

在我们的应用程序中,我们使用深层链接。它们在应用程序打开或在后台运行时工作,但在应用程序完全关闭时不起作用。 应用程序打开,但 OnNewIntent 和

回答 1 投票 0

Xamarin 表单数据绑定问题,视图未更新

我没有对整个页面使用绑定上下文页面或 x:DataType。我对每个组件使用单独的 x:DataType。如下所示: 主要问题是第一个组件的行为为 exp...

回答 1 投票 0

Xamarin iOS 图标设置

“我正在尝试在 Windows 设备上为我使用 Xamarin Forms 开发的 iOS 应用程序设置图标,但我似乎无法做到这一点。我已尝试了所有建议的方法,但它不起作用。我可以吗? ...

回答 1 投票 0

如何在wpf中的xamarin表单中隐藏标题栏

我想使用新的 MVVM 在 WPF 中的 Xamarin 表单中隐藏标题栏。我想在全屏模式下显示我的播放器页面,没有任何边框,并隐藏最小化、最大化和关闭按钮 我用过

回答 1 投票 0

为什么我的工具栏没有显示溢出图标?

我的主要活动使用无操作栏主题。我改用工具栏。现在我设计了一个菜单文件,用于填充工具栏右侧的图标。菜单文件的标记如下所示 <

回答 1 投票 0

如何将 Xamarin ImageSource 转换为像素操作格式(例如 SkiaSharp 或 GDI)?

我正在开发一个 Xamarin.Forms 项目,我需要对通过 Xamarin 的 ImageSource 加载的图像执行像素级操作。我正在寻找一种将 ImageSource 转换为格式的方法...

回答 1 投票 0

.NET MAUI 更改默认后退按钮行为

在我正在使用 MVVM 模式开发的 .NET MAUI 移动应用程序(目标设备:Android)中,当执行从主页到子页面的一些导航以便从某个特定位置返回时...

回答 1 投票 0

Xamarin iOS Firebase 分析

我不明白如何使用参数中的数组项来记录事件。 例如,如果我需要记录类似 EventNamesConstants.Login 的内容,我可以这样做 var 参数 = 新字典 我不明白如何使用参数中的数组项来记录事件。 例如,如果我需要记录类似 EventNamesConstants.Login 的内容,我可以这样做 var parameters = new Dictionary<object, object> { ParameterNamesConstants.Method, "Google" } }; Analytics.LogEvent(EventNamesConstants.Login, parameters); 但现在我需要登录EventNamesConstants.ViewItem 参数之一是项目数组,其中项目有名称。 当我尝试做类似的事情时 var items = new[]{ new Dictionary<object, object> { ParameterNamesConstants.ItemName, title } } }; var parameters = new Dictionary<object, object> { ParameterNamesConstants.Currency, currencyCode }, ParameterNamesConstants.Value, value }, ParameterNamesConstants.Items, items } }; 我收到一个错误。 我试图找到示例,但他们没有数组。 非常抱歉。 错误是: 不知道如何封送类型的对象 'System.Collections.Generic.Dictionary`2[System.Object,System.Object][]' to an NSObject Firebase 的 func Analytics.LogEvent 是: public static void LogEvent (string name, Dictionary<object, object>? parameters) { LogEvent (name, (parameters == null) ? null : ((parameters!.Keys.Count == 0) ? new NSDictionary<NSString, NSObject> () : NSDictionary<NSString, NSObject>.FromObjectsAndKeys (parameters!.Values.ToArray (), parameters!.Keys.ToArray (), nint.op_Implicit (parameters!.Keys.Count)))); } 请帮助我。 作为解决方法,您可以尝试以下方法来创建参数, var keys = new[] { new NSString("key1"), new NSString("key2"), }; var objects = new NSObject[] { new NSString("object1"), new NSString("object1"), }; NSDictionary dicionary = new NSDictionary<NSString, NSObject>(keys, objects); NSArray items = NSArray.FromNSObjects(dicionary); var parameters = new Dictionary<object, object> { { ParameterNamesConstants.Currency, currencyCode }, { ParameterNamesConstants.Value, value }, { ParameterNamesConstants.Items, items } }; 我还在我的应用中使用 Firebase Analytics。 这是 IDictionary<string, string> 上合适的扩展方法,任何人都可以使用它轻松地将 C# IDictionary 转换为 iOS NSDictionary /// <summary> /// Converts an <see cref="IDictionary{TKey, TValue}"/> of string key-value pairs to an <see cref="NSDictionary"/> of <see cref="NSString"/> keys and <see cref="NSObject"/> values. /// </summary> /// <param name="dictionary">The dictionary to convert. Cannot be null.</param> /// <returns>An <see cref="NSDictionary"/> with <see cref="NSString"/> keys and <see cref="NSObject"/> values corresponding to the entries in the input dictionary.</returns> /// <exception cref="ArgumentNullException">Thrown if the input dictionary is null.</exception> /// <remarks> /// This method iterates over the input dictionary to create a pair of arrays for keys and values, which are then used to construct the NSDictionary. /// It's designed to be used as an extension method for any IDictionary&lt;string, string&gt; instance. /// Note: Null keys or values in the input dictionary will result in exceptions, as <see cref="NSString"/> cannot be instantiated with a null reference. /// </remarks> /// <example> /// <code> /// var myDict = new Dictionary&lt;string, string&gt; { { "key1", "value1" }, { "key2", "value2" } }; /// var nsDict = myDict.ToNSDictionary(); /// </code> /// </example> public static NSDictionary<NSString, NSObject> ToNSDictionary(this IDictionary<string, string> dictionary) { ArgumentNullException.ThrowIfNull(dictionary); var keysAndValues = dictionary .Select(kv => (Key: new NSString(kv.Key), Value: new NSString(kv.Value))) .ToArray(); var keys = keysAndValues .Select(kv => kv.Key) .ToArray(); var values = keysAndValues .Select(kv => kv.Value) .ToArray(); return new NSDictionary<NSString, NSObject>(keys, values); } 如果您需要,这里还有一份 IDictionary<string, object> /// <summary> /// Converts an <see cref="IDictionary{TKey, TValue}"/> of string key-value pairs to an <see cref="NSDictionary"/> of <see cref="NSString"/> keys and <see cref="NSObject"/> values. /// </summary> /// <param name="dictionary">The dictionary to convert. Cannot be null.</param> /// <returns>An <see cref="NSDictionary"/> with <see cref="NSString"/> keys and <see cref="NSObject"/> values corresponding to the entries in the input dictionary.</returns> /// <exception cref="ArgumentNullException">Thrown if the input dictionary is null.</exception> /// <remarks> /// This method iterates over the input dictionary to create a pair of arrays for keys and values, which are then used to construct the NSDictionary. /// It's designed to be used as an extension method for any IDictionary&lt;string, object&gt; instance. /// Note: Null keys or values in the input dictionary will result in exceptions, as <see cref="NSString"/> cannot be instantiated with a null reference. /// </remarks> /// <example> /// <code> /// var myDict = new Dictionary&lt;string, object&gt; { { "key1", object1 }, { "key2", object2 } }; /// var nsDict = myDict.ToNSDictionary(); /// </code> /// </example> public static NSDictionary<NSString, NSObject> ToNSDictionary(this IDictionary<string, object> dictionary) { ArgumentNullException.ThrowIfNull(dictionary); var keys = dictionary.Keys .Select(arg => new NSString(arg)) .ToArray(); var objects = dictionary.Values .Select(NSObject.FromObject) .ToArray(); return new NSDictionary<NSString, NSObject>(keys, objects); } 仅供参考:我使用 ArgumentNullException.ThrowIfNull => 仅自 C#10 起可用,如果您在 C#10 下,请使用经典方法。

回答 2 投票 0

如何在 Xamarin Android 中将文件保存到用户选择的目录中?

我有一个图像编辑应用程序,并且有一个按钮,当用户点击它时,应该将文件保存到外部存储。单击此按钮后,我将启动一个活动,供用户选择直接...

回答 1 投票 0

在 SkiaSharp 中渲染多字符表情符号

我正在 SkiaSharp 中渲染表情符号,并且能够使其正确处理简单的表情符号(如 👶 或 😂),但不能正确处理更复杂的表情符号(如 👶🏻 或 👩🏼u200d🎨)。 最棘手的部分是设置...

回答 1 投票 0

相机无法在工作配置文件上工作 - Xamarin Android

我使用 Xamarin 为 Android 设备开发了一个应用程序。我正在使用 Xamarin.Essentials 包中的媒体选择器。在我的工作场所,我们有两种类型的设备 - 一种具有工作配置文件...

回答 1 投票 0

不使用“using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;”时未定义“Stream”类

我正在尝试将图像源从 Xamarin ImageButton 控件转换为 SkiaSharp 位图。我发现当我尝试在不使用 Xamarin.Fo 的情况下使用 Stream 类时,未定义 Stream 类...

回答 1 投票 0

xaml onPlatform 日期时间绑定

有了 DatePicker,我尝试仅为 Android 设备设置 MaximumDate 属性。 有了 DatePicker,我正在尝试仅为 Android 设备设置 MaximumDate 属性。 <DatePicker x:Name="FromDatePicker" BackgroundColor="Transparent" FontSize="15" Grid.Row="0" Grid.Column="0" Margin="{OnPlatform iOS='5, 0, 0, 0'}" HorizontalOptions="Start" Date="{Binding FromDate}" MaximumDate="{OnPlatform Android={Binding FromMaximumDate}}"> </DatePicker> 我也尝试过以下方法: <DatePicker x:Name="FromDatePicker" BackgroundColor="Transparent" FontSize="15" Grid.Row="0" Grid.Column="0" Margin="{OnPlatform iOS='5, 0, 0, 0'}" HorizontalOptions="Start" Date="{Binding FromDate}"> <DatePicker.MaximumDate> <OnPlatform x:TypeArguments="sys:DateTime"> <On Platform="Android" Value="{Binding FromMaximumDate}"/> </OnPlatform> </DatePicker.MaximumDate> </DatePicker> 但这不起作用。我只是得到指定的演员无效。实现此目的的正确语法是什么? 对于那些遇到同样问题的人。您可以使用 TypeArguments="BindingBase"。最有可能的 vs 将显示 xaml 错误属性不支持“Onplatform”1(BindingBase)类型的值但无论如何都会工作。 <DatePicker x:Name="FromDatePicker" BackgroundColor="Transparent" FontSize="15" Grid.Row="0" Grid.Column="0" Margin="{OnPlatform iOS='5, 0, 0, 0'}" HorizontalOptions="Start" Date="{Binding FromDate}"> <DatePicker.MaximumDate> <OnPlatform x:TypeArguments="BindingBase" Android="{Binding ToMinimumDate}"/> </DatePicker.MaximumDate> </DatePicker>

回答 1 投票 0

Xamarin 项目中的权限访问重复对话框 - 仅在 ios 中

我有一个 Xamarin Prism Forms 应用程序,其中包含应该获取用户当前位置的网页。 该应用程序已拥有 Android 所需的“应用程序”权限。但在ios中,当我打电话时...

回答 2 投票 0

Xamarin Forms 适用于 Facebook Audience Network 的 iOS 渲染器

我使用 Xamarin Forms 开发了一个跨平台应用程序,运行良好。现在,我想在应用程序中显示广告,所以我阅读了一些文章并浏览了一些 YouTube 视频 https://www.y...

回答 2 投票 0

Facebook Audience Network 的 Xamarin.Forms 实现

我正在努力在我的 Xamarin.Forms 应用程序中实施 Facebook Audience Network。 可用的 nuget 包很旧并且具有过时的方法。 我能够自己实现广告,测试插播......

回答 2 投票 0

如何在 iOS 设备上的 xamarin Forms Timepicker 中以英语设置 AM/PM

我无法使用 Xamarin 表单中的 TimePicker 发送上午和下午的英语。我已经使用自定义渲染进行了测试,但没有运气。问题仅发生在 iOS 设备中,而不是模拟器中。 [![ 我无法使用 Xamarin 表单中的 TimePicker 发送上午和下午的英语。我已经使用自定义渲染进行了测试,但没有运气。问题仅发生在 iOS 设备中,而不是模拟器中。 [![<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="TTTTT.MainPage"> <StackLayout> <Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0"> <Label Text="Welcome to Xamarin.Forms!" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/> </Frame> <Label Text="Start developing now" FontSize="Title" Padding="30,10,30,10"/> <Label Text="Make changes to your XAML file and save to see your UI update in the running app with XAML Hot Reload. Give it a try!" FontSize="16" Padding="30,0,30,0"/> <Label FontSize="16" Padding="30,24,30,0"> <Label.FormattedText> <FormattedString> <FormattedString.Spans> <Span Text="Learn more at "/> <Span Text="https://aka.ms/xamarin-quickstart" FontAttributes="Bold"/> </FormattedString.Spans> </FormattedString> </Label.FormattedText> </Label> <TimePicker Format="h:mm tt"></TimePicker> </StackLayout> </ContentPage>][1]][1] iOS 中的本地化是您所需要的,您可以在 Info.plist 中指定默认和支持的语言,并将 floder.lproj 中支持的 .strings 文件添加到您的项目中。如果您有资源文件并添加本地化语言的键值对,它将可用。如果用户在“设置”中设置了“首选语言”,iOS会首先自动查找用户最喜欢的语言。您可以参考:iOS如何确定您的应用程序的语言。 <key>CFBundleLocalizations</key> <array> <string>en</string> <string>es</string> </array> <key>CFBundleDevelopmentRegion</key> <string>en</string 您还可以设置 AppleLanguages 来更改语言: NSUserDefaults.StandardUserDefaults.SetValueForKey(NSArray.FromStrings("XX"), new NSString("AppleLanguages")); NSUserDefaults.StandardUserDefaults.Synchronize(); 欲了解更多信息,您可以参考: Xamarin.iOS 中的本地化 Xamarin.Forms 字符串和图像本地化

回答 1 投票 0

MAUI.NET 7 中的 Firebase/google-services.json 相关构建问题

问候, 使用适用于 Android 的 Visual Studio 2022、MAUI.NET 7 我正在尝试向 Android MAUI.NET 7 应用程序添加 Firebase 推送支持。我已经浏览过指南了。我已经把后端部分全部平方了......

回答 2 投票 0

Microsoft MAUI:在 MAUI APP 中使用 Azure SQL 的最佳实践是什么

我想将我的 Azure SQL(或外部数据库)连接到我的 Microsoft MAUI 应用程序。 实现这一目标的最佳实践是什么?

回答 2 投票 0

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