Сбой сборки при попытке собрать Xamarin. ios .csproj. Работает в режиме отладки. Я только что реализовал режим темный / светлый, и он работает в режиме отладки, только сбой при попытке построить. Посмотрел версию SDK, версию xamarin и размещенный агент macOS. Выглядит хорошо, но не уверен, почему не распознает свойство 'UserInterfaceStyle'. Кто-нибудь сталкивался с этим вопросом раньше? Любая идея?
Вот мой код код страницы:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Foundation;
using Mobile.Base;
#if ACCUROUND
using Mobile.AccuRound;
#endif
#if LOCATE
using Mobile.Locate;
#endif
#if ROGER
using Mobile.Roger;
#endif
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(ContentPage), typeof(Mobile.Base.iOS.PageRenderer))]
namespace Mobile.Base.iOS
{
public class PageRenderer : Xamarin.Forms.Platform.iOS.PageRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (e.OldElement != null || Element == null)
{
return;
}
try
{
SetAppTheme();
}
catch (Exception ex)
{
Console.WriteLine($"\t\t\tERROR: {ex.Message}");
}
}
public override void TraitCollectionDidChange(UITraitCollection previousTraitCollection)
{
base.TraitCollectionDidChange(previousTraitCollection);
if (previousTraitCollection != null && TraitCollection.UserInterfaceStyle != previousTraitCollection.UserInterfaceStyle)
{
SetAppTheme();
}
}
private void SetAppTheme()
{
if (TraitCollection.UserInterfaceStyle == UIUserInterfaceStyle.Dark)
{
if (App.AppTheme == "dark")
return;
App.Current.Resources = new DarkTheme();
App.AppTheme = "dark";
}
else
{
if (App.AppTheme != "dark")
return;
App.Current.Resources = new LightTheme();
App.AppTheme = "light";
}
}
}
}