MonoTouch:如何从TabBarController的多个视图中选择初始视图 [英] MonoTouch: how to select initial view from TabBarController's multiple views

查看:95
本文介绍了MonoTouch:如何从TabBarController的多个视图中选择初始视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有5个TabBar视图...如何选择应用程序首次启动时出现的视图? (我使用在应用启动时为null的数据进行了一些计算).该应用程序在崩溃之前甚至崩溃了!以及如何确定哪个视图将成为第一个视图?

I have 5 TabBar views... how do I select which view appears when the app first starts? (I have some computations using data that is null at app start time). The app crashes BEFORE it even gets to FinishedLaunching! And how does it determine which view is going to be the first one?

上一个答案是我建议的tabBarController.SelectedIndex = 0; (我正在使用MonoTouch) 但是没有告诉我在哪里放置.

One previous answer I got suggested tabBarController.SelectedIndex = 0; (I'm using MonoTouch) but didn't tell me where to place it.

推荐答案

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

this.ViewControllers = u;
this.SelectedViewController = tab1;

我通常将UITabBarController子类化,并在我重写的ViewDidAppear方法中添加上面的代码.

I typically sub-class the UITabBarController and add the code above in the ViewDidAppear method that I override.

这篇关于MonoTouch:如何从TabBarController的多个视图中选择初始视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆