繁体   English   中英

Xamarin形成带有导航页面的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
}

现在,正如他们在美国所说的那样,百万美元的问题是:我们如何解决这个“谜”?

预先非常感谢您提供的所有答案和支持(使用这种.. ah工具,也称为Xamarin)。

这就是我所做的。 在您的App.cs(或主项目类)中,您需要创建一个新的NavigationPage,其中包含TabbedPage,使用导航控制器,您将拥有一个导航上下文,并且如果您不想这样做,则可以将您下一页推入页面在顶部有一个导航栏,您可以按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";
    }
}

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM