我們正在開發一個 MAUI 應用程式,并且在導航到選項卡時遇到問題。
我們有一個帶有 的 shell 應用程式,其中TabBar我們定義了 5 個選項卡:
<TabBar>
<Tab Title="Home"
Icon="homeicon.png">
<ShellContent ContentTemplate="{DataTemplate Pages:FeedPage}" />
</Tab>
<Tab Title="Messages"
Icon="messageicon.png">
<ShellContent ContentTemplate="{DataTemplate Pages:MessagesPage}" />
...
</TabBar>
我們還在其中一個選項卡 xaml 中定義了 Shell.TitleView,如下所示:
<Shell.TitleView>
<Grid Padding="5" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<ImageButton Grid.Column="2" Source="profileicon.png"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand"
Command="{Binding ProfileButtonTapped }" />
<ImageButton Grid.Column="1" Source="coinicon.png"
...
...
</Grid>
</Shell.TitleView>
當我們嘗試回傳定義了 Shell.TitleView 的選項卡時,就會出現問題。我們得到的錯誤是:
Java.Lang.IllegalStateException: '指定的孩子已經有一個父母。您必須首先在孩子的父母上呼叫 removeView()。
標題視圖上的 StackLayout 也會出現此錯誤……我們進行了一些挖掘,發現如果我們從 TitleView 中洗掉布局,則該錯誤不再發生,因此我們猜測它與此有關。
編輯1:每次切換標簽時我都注意到了這個輸出
“執行緒已完成:#11 執行緒 0xb 已退出,代碼為 0 (0x0)。執行緒已啟動:#12 執行緒已完成:#10 執行緒 0xa 已退出,代碼為 0 (0x0)。不支持 [TabLayout] MODE_SCROLLABLE GRAVITY_FILL,將使用 GRAVITY_START"
uj5u.com熱心網友回復:
不幸的是,當從 Shell Tab #4506 導航回到它時, 它是 MAUI 本身的一個已知錯誤Page with TitleView 在 Android 上崩潰
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/443427.html
標籤:xml xamarin.forms.shell .net-maui
