我有一个选项卡式页面,其中有5个视图控制器作为子级。在初始化时,将出现第一个子项,然后,如果我导航到另一页并移回第一页,然后再次导航到另一页,则应用程序崩溃。
这是我的标签页:
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
android:TabbedPage.ToolbarPlacement="Bottom"
android:TabbedPage.BarItemColor="#66FFFFFF"
android:TabbedPage.BarSelectedItemColor="White"
BarBackgroundColor="#00abbf"
NavigationPage.HasNavigationBar="False"
x:Class="project.App.Common.Views.Dashboard.dashboardview">
</TabbedPage>
这是我后面的选项卡式页面代码:
var view1= new View1{ Icon= "icon.png" };
var view2 = new View2 { Icon = "icon.png" };
var view3= new View3 { Icon="icon.png" };
var view4= new View4 { Icon = "icon.png" };
var view5 = new View5 { Icon = "icon.png" };
Children.Add(view1);
Children.Add(view2);
Children.Add(view3);
Children.Add(view4);
Children.Add(view5);
在应用启动时,先加载view1,然后转到view2,然后导航回到view1,然后再次移至view2,应用程序崩溃了。
崩溃日志是:
No package identifier when getting name for resource number 0x00000005
No view found for id 0x5 (unknown) for fragment FragmentContainer{f99bdc5 #0 id=0x5 android:switcher:5:629936758}
Activity state:
Local Activity e5cedd4 State:
mResumed=true mStopped=false mFinished=false
mChangingConfigurations=false
mCurrentConfig={1.07 404mcc7mnc en_US ldltr sw360dp w360dp h616dp 240dpi nrml long port finger -keyb/v/h -nav/h s.370 themeId=0, affectGlobal:true}
mLoadersStarted=true
Active Fragments in 46948a7:
#0: ReportFragment{d210154 #0 android.arch.lifecycle.LifecycleDispatcher.report_fragment_tag}
mFragmentId=#0 mContainerId=#0 mTag=android.arch.lifecycle.LifecycleDispatcher.report_fragment_tag
mState=5 mIndex=0 mWho=android:fragment:0 mBackStackNesting=0
mAdded=true mRemoving=false mResumed=true mFromLayout=false mInLayout=false
mHidden=false mDetached=false mMenuVisible=true mHasMenu=false
mRetainInstance=false mRetaining=false mUserVisibleHint=true
mFragmentManager=FragmentManager{46948a7 in HostCallbacks{6d58fd}}
mHost=android.app.Activity$HostCallbacks@6d58fd
Child FragmentManager{5a29f2 in ReportFragment{d210154}}:
FragmentManager misc state:
mHost=android.app.Activity$HostCallbacks@6d58fd
mContainer=android.app.Fragment$1@257c843
mParent=ReportFragment{d210154 #0 android.arch.lifecycle.LifecycleDispatcher.report_fragment_tag}
mCurState=5 mStateSaved=false mDestroyed=false
Added Fragments:
#0: ReportFragment{d210154 #0 android.arch.lifecycle.LifecycleDispatcher.report_fragment_tag}
FragmentManager misc state:
mHost=android.app.Activity$HostCallbacks@6d58fd
mContainer=android.app.Activity$HostCallbacks@6d58fd
mCurState=5 mStateSaved=false mDestroyed=false
ViewRoot:
mAdded=true mRemoved=false
mConsumeBatchedInputScheduled=true
mConsumeBatchedInputImmediatelyScheduled=false
mPendingInputEventCount=0
mProcessInputEventsScheduled=false
mTraversalScheduled=true (barrier=76)
android.view.ViewRootImpl$NativePreImeInputStage: mQueueLength=0
android.view.ViewRootImpl$ImeInputStage: mQueueLength=0
android.view.ViewRootImpl$NativePostImeInputStage: mQueueLength=0
Choreographer:
mFrameScheduled=true
mLastFrameTime=119331759 (84 ms ago)
不知道为什么会这样。我使用的是XF 3.4.0,孩子是正常的内容页面。
有人可以帮我吗?
谢谢。