如何重写UINavigationController的构造函数以传入rootViewController?Monotouch:UINavigationController,覆盖initWithRootViewController
我会像在Objective-C以下的方法:
-(id)initWithRootViewController:(UIViewController*)rootViewController
{
UIViewController *fakeController = [[[UIViewController alloc] init] autorelease];
if (self = [super initWithRootViewController:fakeController]) {
self.fakeRootViewController = fakeController;
rootViewController.navigationItem.hidesBackButton = YES;
[self pushViewController:rootViewController animated:NO];
}
return self;
}
预先感谢您。问候。
P.S的这段代码已采取从Change the root view controller
编辑:
谢谢您的答复。我对前面的代码片断感兴趣,因为它特别有趣。
@Geoff诺顿:也许我会永远不可能用你的解决方案,但我觉得很神奇呢?
我的尝试是创造一种UINavigationViewController,它充当一个模板。尤其是,UINavigationController最初有一个loginView(它可能是一种rootviewcontroller)。然后登录时,我可以有两种类型的视图:主视图和次视图。前者与登录视图处于同一级别(它们可能是一种rootview控制器)。后者被推到第一个以上。您可以浏览普通的UInavigationController堆栈或工具栏。工具栏只加载主视图。
是否可以用UINavigationController来做到这一点?
再次感谢您。问候。