Xamarin.Forms.Application.Current.MainPage为空
我有一个不寻常的场景,我正在将应用程序从iOS迁移到表单 我的设置是-Xamarin.Forms.Application.Current.MainPage为空,xamarin.forms,xamarin.ios,prism,application-lifecycle,Xamarin.forms,Xamarin.ios,Prism,Application Lifecycle,我有一个不寻常的场景,我正在将应用程序从iOS迁移到表单 我的设置是- iOS项目加载签名UIViewController和handelling登录例程。 主页为空 登录例程完成后,我将XF视图作为UIViewController加载,并将其添加到导航堆栈中 var formscocontroller=formsPage.CreateViewController(); CoreApplication.Instance.FormsController=FormsController; var
var formscocontroller=formsPage.CreateViewController();
CoreApplication.Instance.FormsController=FormsController;
var CurrentNavigationController=UIApplication.SharedApplication.KeyWindow.RootViewController;
var VIEWCONTROLLERSTACK=CurrentNavigationController.ChildViewController;
viewControllersStack[viewControllersStack.Length-1].NavigationController.PushViewController(CoreApplication.Instance.FormsController,true);
这就是主页具有导航值的时候,将其设置为导航页面
protectedoverride void OnSleep()
{
if(Application.Current.MainPage!=null)
{
Console.WriteLine(“!!!!-->”+Application.Current.MainPage.GetType().Name);
}
}
我正在获取主页的名称-所以该值不为空
或者do=>MainPage=newmypage();然后,主页实例在所有应用程序生命周期中都保持活动状态。从评论到原始帖子,问题的解决方法是在XF成为应用程序启动时的第一响应者时移动应用程序逻辑。然后,当需要加载UIViecontrollers时,我将正常管理导航-获取UIApplication.SharedApplication.KeyWindow以显示ViewController
有关如何执行此操作的更多详细信息,请参见,这意味着您的问题现在已解决?是和否。问题保持不变。目前,我正在研究的解决方案(仍在摸索导航)来自我的Post Scriptum=>我必须将应用程序从Xamarin.iOS first/Xamarin.Forms second转换为Xamarin.iOS second/Xamarin.Forms first。我一做完就在这里发布结果。