简体   繁体   English

在MonoCross.Touch应用程序中使用“ MXTouchViewGroup *”的MonoCross示例

[英]MonoCross Example using “MXTouchViewGroup*” in a MonoCross.Touch application

Does anyone have example code illustrating how one would use the "MXTouchViewGroup*" code in the framework to create/use a tab bar at the bottom. 是否有人在示例代码中说明了如何使用框架中的“ MXTouchViewGroup *”代码在底部创建/使用选项卡栏。 Looking at code for MXToughViewGroup*, it isn't 100% clear how I would setup/use the navigation framework with a tab bar. 在查看MXToughViewGroup *的代码时,尚不清楚我将如何使用选项卡栏设置/使用导航框架。 Unfortunately the MonoCross book also has no examples of this case. 不幸的是,MonoCross书中也没有这种情况的例子。

Any help would be appreciated. 任何帮助,将不胜感激。

Thanks in Advance. 提前致谢。

So after poking around in MonoCross source, I've figured out how one would use a MonoTouch/iOS tab bar while using the MonoCross pattern, and specifically while continuing to use MonoCross.Navigation to move around your app: 因此,在浏览MonoCross源代码之后,我想出了在使用MonoCross模式时,特别是在继续使用MonoCross.Navigation在应用程序中移动时,如何使用MonoTouch / iOS选项卡栏:

//------- MonoCross Shared Application

// Main Menu
NavigationMap.Add("Menu/Tab1", new Tab1Controller());
NavigationMap.Add("Menu/Tab2", new Tab2Controller());
NavigationMap.Ass("Other", new OtherController());

// Set default navigation URI
NavigateOnLoad = "Menu/Tab1";

//------- MonoCross.Touch Container

// init monocross application
MXTouchContainer.Initialize(new SharedApplication(), this, window)

// Add view to container as usual
MXTouchContainer.AddView<ModelTab1>(typeof(Tab1View),ViewPerspective.Default);
MXTouchContainer.AddView<ModelTab2>(typeof(Tab2View),ViewPerspective.Default);
MXTouchContainer.AddView<ModelOther>(typeof(OtherView),ViewPerspective.Default);

// Create a MXTouchViewGroup, with items representing tab items     
MXTouchViewGroupItem[] menuItems = new MXTouchViewGroupItem[] {
        new MXTouchViewGroupItem(typeof(Tab1View),"Tab 1!",""),
        new MXTouchViewGroupItem(typeof(Tab2View),"Tab 2!",""), 
            };
MXTouchViewGroup tvg = new MXTouchViewGroup(new MXTouchViewGroupTabController(),menuItems);

// Add the group to MXTouchContainer.ViewGroups 
List<MXTouchViewGroup> ltvg = ((MXTouchContainer)MXTouchContainer.Instance).ViewGroups;
ltvg.Add(tvg);

// navigate to to starting location now
MXTouchContainer.Navigate(null,MXTouchContainer.Instance.App.NavigateOnLoad);

In the shared app, create controllers derived from MXController as usual and add them to the NavigationMap. 在共享应用程序中,照常创建从MXController派生的控制器,并将它们添加到NavigationMap。 Absolutely nothing special to be done in the "Shared Application" 绝对不需要在“共享应用程序”中做任何特别的事情

In The MonoCross Container, you add views derived from MXTouch*View as usual to the container as usual as well. 在MonoCross容器中,您还可以照常向容器添加从MXTouch * View派生的视图。 What is done differently is to create a "MXTouchViewGroup" with one "MXTouchViewGroupItems" created for each tab; 不同的是创建一个“ MXTouchViewGroup”,并为每个选项卡创建一个“ MXTouchViewGroupItems”。 each "MXTouchViewGroupItem" has one of your views associated to it. 每个“ MXTouchViewGroupItem”都有一个与之关联的视图。 You'll want to create an appropriate "MXTouchViewGroup" item for your tab bar, and then add the group to your "MXTouchContainer" as shown, and then let the framework navigate to the first view as usual. 您将要为选项卡栏创建一个适当的“ MXTouchViewGroup”项,然后如图所示将组添加到“ MXTouchContainer”,然后让框架照常导航至第一个视图。

The result of all this is that when navigating to a view that is in a "group" (ie "Tab1View" or "Tab2View"), the framework will automagically render a tab bar with the view, without any further intervention. 所有这些的结果是,当导航到“组”中的视图(即“ Tab1View”或“ Tab2View”)时,框架将自动使用该视图渲染选项卡栏,而无需任何其他干预。 If you navigate to a view that isn't in a "group" (ie "OtherView"), the tabbar will not render. 如果导航到不在“组”中的视图(即“ OtherView”),则标签栏将不会呈现。

That's it. 而已。

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

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