我用iPad,Android平板电脑创建了应用程序,使用Navigation和MasterDetail方法Lemme解释了如下的应用场景:
第一页包含登录表单,因此我从主页面导航登录页面,如下所示。
public App()
{
// The root page of your application
var nav = new NavigationPage(new LoginViewController());
nav.BarBackgroundColor = Color.FromHex("#EEEEEE");
nav.BarTextColor = Color.FromHex("#424242");
MainPage = nav;
}
现在,一旦用户完成登录活动,我想将应用程序移动到主屏幕,如下所示。
async void OnButtonClickedLogin(object sender, EventArgs args)
{
// As per having some REST call in this I made this method as async
HomeViewController test = new HomeViewController();
await test.loadTopLoan_Datas();
await this.Navigation.PushAsync(test);
}
现在,主屏幕包含列表视图的详细信息列表。因此,一旦用户点击列表项,我想将下一个屏幕作为MasterDetail页面移动,如下所示。
listView.ItemSelected += (sender, e) =>
{
Navigation.PushAsync(new NavigationPage(new LeadViewController()));
}
因此上面的操作将leadViewController主详细信息页面移动到平板电脑中,但是当我在Android平板电脑上运行构建时,它提到了以下错误:
在下面附加LeadViewController主详细信息页面源:
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace eMO_Xamarin
{
public class LeadViewController : MasterDetailPage
{
public static INavigation Navi
{
get;
set;
}
public LeadViewController()
{
this.BackgroundImage = "Bg6.jpg";
NavigationPage.SetBackButtonTitle(this, "");
NavigationPage.SetHasBackButton(this, false);
NavigationPage.SetHasNavigationBar(this, false);
this.Title = "Lead section";
var menuPage = new MenuPage();
menuPage.OnMenuSelect = (categoryPage) =>
{
Detail = new NavigationPage(categoryPage);
if (Device.Idiom == TargetIdiom.Phone)
{
IsPresented = false;
}
else if (Device.Idiom == TargetIdiom.Tablet)
{
IsPresented = true;
}
else {
IsPresented = true;
}
};
Master = menuPage;
var letsGetPage = new NavigationPage(new LetsGetStartedPage());
Detail = letsGetPage;
MasterBehavior = MasterBehavior.Default;
}
}
}
Android只允许一个导航页面
因此,在这种情况下,我如何在iOS和Android平台上很好地管理这种情况。如何从现有的Navigation推送管理masterDetail页面场景?