gpt4 book ai didi

android - Xamarin Forms MasterDetail 页面导航导致 Android 崩溃 [致命信号 6 (SIGABRT),代码 -6],适用于 iOS 和 UWP

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:14:48 25 4
gpt4 key购买 nike

我有一个像下面这样的主细节

public partial class LeaguesMDPage : MasterDetailPage
{
public LeaguesMDPage()
{
InitializeComponent();
Master = new LeaguesPage();
Detail = new NavigationPage(new DivisionsPage(new League()));
}
}

League Page(Master)设计有如下 ListView

    <ListView
ItemsSource="{Binding Leagues}"
SelectedItem="{Binding SelectedLeague, Mode=TwoWay}"
IsPullToRefreshEnabled="True"
RefreshCommand="{Binding UpdateLeagues}"
IsRefreshing="{Binding IsBusy}"
>

后面的代码是

public partial class LeaguesPage : ContentPage
{
LeaguesViewModel vm;

public LeaguesPage()
{
InitializeComponent();
BindingContext = vm = new LeaguesViewModel(this);
}
protected override void OnAppearing()
{
base.OnAppearing();
vm.UpdateLeagues.Execute(false);
}
}

在 LeaguesViewModel 中,我有 SelectedLeague 属性 setter 更新详细信息页面并像这样隐藏 Master

League _SelectedLeague;

public League SelectedLeague
{
get { return _SelectedLeague; }
set
{
_SelectedLeague = value;
OnPropertyChanged();
if (_SelectedLeague != null)
{
Debug.WriteLine($"Navigating to DivisionsPage with LeagueID {_SelectedLeague.ID}");
var mdp = (MasterDetailPage)App.Current.MainPage;
Device.OnPlatform(
Android: () => { mdp.IsPresented = false; },
iOS: () => { mdp.IsPresented = false; },
WinPhone: () => { },
Default: () => { mdp.IsPresented = false; }
);
mdp.Detail = new NavigationPage(new DivisionsPage(_SelectedLeague));
_SelectedLeague = null;
}
}
}

有时这似乎确实像我希望的那样起作用。它导航到新的 DivisionsPage 并隐藏母版。似乎在 iOS 和 UWP 上运行良好,但它在 Android 上崩溃并出现以下问题

[0:] Server Returned 34 divisions
[0:] Navigating to DivisionsPage with LeagueID 12
[0:] UpdatePoolRankings: Called GetDivisionsAsync
03-23 02:40:52.151 W/Mono ( 6249): The request to load the assembly System.Core v4.0.0.0 was remapped to v2.0.5.0
03-23 02:40:52.151 D/Mono ( 6249): Unloading image System.Core.dll [0x99db7700].
03-23 02:40:52.151 D/Mono ( 6249): Image addref System.Core[0xaec169a0] -> System.Core.dll[0x9d166d00]: 11
03-23 02:40:52.151 D/Mono ( 6249): Config attempting to parse: 'System.Core.dll.config'.
03-23 02:40:52.151 D/Mono ( 6249): Config attempting to parse: '/Users/builder/data/lanes/4009/f3074d2c/source/monodroid/builds/install/mono-x86/etc/mono/assemblies/System.Core/System.Core.config'.
03-23 02:40:52.152 W/Mono ( 6249): The request to load the assembly System.Core v4.0.0.0 was remapped to v2.0.5.0
03-23 02:40:52.152 D/Mono ( 6249): Unloading image System.Core.dll [0x99db7700].
03-23 02:40:52.152 D/Mono ( 6249): Image addref System.Core[0xaec169a0] -> System.Core.dll[0x9d166d00]: 12
03-23 02:40:52.152 D/Mono ( 6249): Config attempting to parse: 'System.Core.dll.config'.
03-23 02:40:52.152 D/Mono ( 6249): Config attempting to parse: '/Users/builder/data/lanes/4009/f3074d2c/source/monodroid/builds/install/mono-x86/etc/mono/assemblies/System.Core/System.Core.config'.
03-23 02:40:52.383 D/Mono ( 6249): [0x9b5bf930] hill climbing, change max number of threads 4
[0:] Server Returned 3 divisions
03-23 02:40:52.421 F/ ( 6249): * Assertion at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mono/metadata/sgen-tarjan-bridge.c:1139, condition `xref_count == xref_index' not met
03-23 02:40:52.421 F/libc ( 6249): Fatal signal 6 (SIGABRT), code -6 in tid 6249 (ClubApp.Droid)
InspectorDebugSession(21): Disposed
InspectorDebugSession(21): HandleTargetEvent: TargetExited

如果需要更多详细信息,请告诉我,谢谢!

最佳答案

我将您的示例更新到最新版本 2.3.4,它可以在 Android 上正常运行。我建议您删除 MasterDetailPage 中的代码并将其更新为以下内容:

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:ClubApp.Views;assembly=ClubApp"
xmlns:model="clr-namespace:ClubApp.Models;assembly=ClubApp"
x:Class="ClubApp.Views.MainMasterDetailPage"
Title="MD Page"
IsPresented="True">
<MasterDetailPage.Master>
<local:LeaguesPage />
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage>
<x:Arguments>
<local:DivisionsPage>
<x:Arguments>
<model:League />
</x:Arguments>
</local:DivisionsPage>
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
</MasterDetailPage>

关于android - Xamarin Forms MasterDetail 页面导航导致 Android 崩溃 [致命信号 6 (SIGABRT),代码 -6],适用于 iOS 和 UWP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42990427/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com