我使用各种视图类型执行应用程序:MvxViewController,MvxTabBarViewController,...
但是当我想要这样做时,我遇到了困难:遵循初始指令(http://bit.ly/1hLNMF3,http://bit.ly/1hNNY2g),我忽略了导航后退按钮等。
所以,我想混合简单的视图和选项卡式视图而不会丢失Back按钮而不重新编码它(使用NavigationItem.SetLeftBarButtonItem:http://bit.ly/1fsqGEC)。受这些解决方案的启发,我这样做了:
答案 0 :(得分:2)
对于MvxTabBarViewController - 项目详细信息的主控制器:
public partial class SecondView : MvxTabBarViewController {
private int _count = 0;
public SecondView() {
ViewDidLoad();
}
public new SecondViewModel ViewModel {
get { return (SecondViewModel)base.ViewModel; }
set { base.ViewModel = value; }
}
public override void ViewDidLoad() {
base.ViewDidLoad();
if (ViewModel == null) return;
var viewControllers = new UIViewController[] {
CreateTabFor ("tab 1", "t1", ViewModel.Tab1);
CreateTabFor ("tab 2", "t2", ViewModel.Tab2);
CreateTabFor ("tab 3", "t3", ViewModel.Tab3);
}
ViewControllers = viewControllers;
CustomizableViewControllers = new UIViewController[0] { }
SelectedViewController = ViewControllers [0]
}
private UIViewController CreateTabFor (string tabTitle, string tabImage, IMvxViewModel viewModel) {
var controller = new UITabViewController ();
var screen = this.CreateViewControllerFor(viewModel) as UIViewController;
controller.TabBarItem = new UITabBarItem (tabTitle, UIImage.FromBundle("Images/" + tabImage + ".png"), _count);
_count++;
controller.Add (screen.View);
return controller;
}
}
此外,我不需要更改安装程序类。