c# - 使用 Monotouch 如何实现 UITabBarController 作为我的 RootViewController

标签 c# xamarin.ios uitabbarcontroller

我对使用 Monotouch 进​​行 iOS 编程完全陌生...我正在使用此代码来创建我的导航 Root View 。

window = new UIWindow(UIScreen.MainScreen.Bounds);

UINavigationController rootNavController = new UINavigationController ();
window.RootViewController = rootNavController;

UIViewController tabView = new TabContainer ();
rootNavController.PushViewController (tabView, false);

我的 TabContainer 类继承了 UITabBarController 类,并且我有几个 UIViewController 添加到 UITabBarController 类中。

var tabs = new UIViewController[] {
     tab1, tab2, tab3, tab4, tab5
};

base.ViewControllers = tabs;

单击其中一个选项卡后,我的 ViewController 将在其中加载 UITableView,并且我仍然可以在底部看到 TabBarController。如果我现在单击任何表格单元格,我将推送一个新 View ,并且 TabBarController 被隐藏。

tblSource.OnRowSelected += (object sender, TableSourceStationGroup.RowSelectedEventArgs e) => {
            e.tableView.DeselectRow (e.indexPath, true);
            stationView = new viewStation (itemList[e.indexPath.Row].Name, itemList[e.indexPath.Row].Id, itemList[e.indexPath.Row].Stations);
            this.NavigationController.PushViewController(stationView, true);

当我推送新 View 时,如何防止 TabBarController 隐藏?我认为我缺少一些关于我的应用程序结构的基本内容。

最佳答案

您想要像这样设置层次结构:

                           Tab1 -> Nav1 -> View
Root --> Tab Controller -> Tab2 -> Nav2 -> View
                           Tab3 -> Nav3 -> View

因此每个选项卡都会有自己的导航 Controller ,该 Controller 上会推送一个初始 View 。

在您的示例中,您将 Nav Controller 作为根,包含 Tab Controller 。这是倒退的 - 您希望 Tab Controller 包含 Nav Controller 。

关于c# - 使用 Monotouch 如何实现 UITabBarController 作为我的 RootViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19453273/

相关文章:

c# - 在 C# 中等效于 java 的 ConcurrentHashMap?

c# - 将 StreamReader 转换为 byte[]

c# - schtasks 表示状态为 "could not start"

ios - xamarin 中的帧偏移

c# - 没有 StackTrace 或日志的 Monotouch 应用程序崩溃(从未调用析构函数)

ios - ios4 中的 TabBar 自定义在 ios5 中不起作用

ios - 在应用程序启动时获取在 UITabBarController 中选择的选项卡的标题

c# - COM 方法调用在 C#、VB.NET 中失败,但在 Python 中有效

ios - Xamarin IOS LaunchScreen.Storyboard 无法为 ImageView 选择图像

c# - 单色触摸 : UITabBarController throws 'loaded the nib but the view outlet was not set'