Xamarin forms iOS 带导航页的标签页
Xamarin forms iOS tabbed page with navigation page
所以,Xamarin 倡导者和其他人,我邀请大家尝试并回答如何让 iOS 的导航页面带有标签页?
听起来很简单,不是吗?对于android,不用担心,没有问题,没有任何异常,可以自定义我需要的任何东西。
另一方面,对于 iOS,尽管我被告知我是不理解 Xamarin 实践的人(或者换句话说,人们需要采取的逃生路线才能做到这一点实际工作),我不能让导航页面和标签页共存,没有问题。
事情是这样的:
if (navigation page contains tabbed page)
{
no title is shown in the navigation bar
}
else if (each content page for the tabbed page is contained in a navigation page)
{
no icon or title is shown in the tab bar
}
else
{
The company manager does not want any else, there has to be a navigation page to allow opening other pages from the contents in each tab, and there has to be tabbed page and navigation bar for iOS
}
现在是美国所说的百万美元问题:我们如何解决这个问题"mystery"?
提前非常感谢您的所有回答和支持(关于使用这种..啊,工具,也称为 Xamarin)。
这就是我所做的。在您的 App.cs(或主项目 class)中,您需要创建一个包含您的 TabbedPage 的新 NavigationPage,使用导航控制器,您将拥有一个导航上下文,并且您可以通过它推送下一页,如果你不想在顶部有一个导航栏,你可以推送 ModalPages 或使用 NavigationPage.SetHasNavigationBar(this, false);
,代码片段:
public class App : Application
{
public App ()
{
MainPage = new NavigationPage(new MainTabbedPage());
}
}
public class MainTabbedPage : TabbedPage
{
public MainTabbedPage()
{
Children.Add(new FirstPage());
Children.Add(new SecondPage());
}
}
public class SecondPage : ContentPage
{
public SecondPage()
{
Title = "Second Page";
var btn = new Button
{
Text = "Click me"
};
btn.Clicked += BtnBlicked;
Content = btn;
}
async void BtnBlicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new ThirdPage());
}
}
public class ThirdPage : ContentPage
{
public ThirdPage()
{
Title = "Third Page";
}
}
所以,Xamarin 倡导者和其他人,我邀请大家尝试并回答如何让 iOS 的导航页面带有标签页?
听起来很简单,不是吗?对于android,不用担心,没有问题,没有任何异常,可以自定义我需要的任何东西。
另一方面,对于 iOS,尽管我被告知我是不理解 Xamarin 实践的人(或者换句话说,人们需要采取的逃生路线才能做到这一点实际工作),我不能让导航页面和标签页共存,没有问题。
事情是这样的:
if (navigation page contains tabbed page)
{
no title is shown in the navigation bar
}
else if (each content page for the tabbed page is contained in a navigation page)
{
no icon or title is shown in the tab bar
}
else
{
The company manager does not want any else, there has to be a navigation page to allow opening other pages from the contents in each tab, and there has to be tabbed page and navigation bar for iOS
}
现在是美国所说的百万美元问题:我们如何解决这个问题"mystery"?
提前非常感谢您的所有回答和支持(关于使用这种..啊,工具,也称为 Xamarin)。
这就是我所做的。在您的 App.cs(或主项目 class)中,您需要创建一个包含您的 TabbedPage 的新 NavigationPage,使用导航控制器,您将拥有一个导航上下文,并且您可以通过它推送下一页,如果你不想在顶部有一个导航栏,你可以推送 ModalPages 或使用 NavigationPage.SetHasNavigationBar(this, false);
,代码片段:
public class App : Application
{
public App ()
{
MainPage = new NavigationPage(new MainTabbedPage());
}
}
public class MainTabbedPage : TabbedPage
{
public MainTabbedPage()
{
Children.Add(new FirstPage());
Children.Add(new SecondPage());
}
}
public class SecondPage : ContentPage
{
public SecondPage()
{
Title = "Second Page";
var btn = new Button
{
Text = "Click me"
};
btn.Clicked += BtnBlicked;
Content = btn;
}
async void BtnBlicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new ThirdPage());
}
}
public class ThirdPage : ContentPage
{
public ThirdPage()
{
Title = "Third Page";
}
}