我们正在致力于毛伊岛的应用程序,并面临一个问题,在导航和到标签。
我们有一个带有TabBar
的shell应用程序,我们在里面定义了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代替”
“。
发布于 2022-03-11 11:21:55
不幸的是,它是毛伊岛本身已知的一个bug,Page with TitleView crashes on Android when navigating back to it from Shell Tab #4506 。
https://stackoverflow.com/questions/71436233
复制相似问题