2 lianlianbushell lianlianbushell 于 2012.11.05 10:04 提问

IOS中如何调用Rootviewcontroller?

我希望在ios应用中能实现查看用户是注册用户还是新用户,如果还没注册的用户,就会转到注册页面。代码如下:

if (user != register){

        RegisterViewController *registerViewController = [[RegisterViewController alloc] init];
                RearViewController *rearViewController = [[RearViewController alloc] init];

        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:registerViewController];

        self.viewController = revealController;

        self.window.rootViewController = self.viewController;

        self.window makeKeyAndVisible];
    }else {

FrontViewController *frontViewController = [[FrontViewController alloc] init];
            RearViewController *rearViewController = [[RearViewController alloc] init];

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController];

RevealController *revealController = [[RevealController alloc] initWithFrontViewController:navigationController rearViewController:rearViewController];

self.viewController = revealController;

self.window.rootViewController = self.viewController;

[self.window makeKeyAndVisible];

}

如果用户没注册,就会进入注册页面

但是有问题,等用户注册完了,在屏幕上方就会出现两个导航控制器。
我用下面的代码将已注册用户导入主页面:

[[self navigationController] pushViewController:revealController animated:YES];

不知道问题在哪里~

1个回答

prettYYoyic
prettYYoyic   2012.11.05 13:56
已采纳

从网上搜来的,

[[UIApplication sharedApplication] keyWindow].rootViewController = revealController;

设置另一个root view controller,看看能实现不?

Csdn user default icon
上传中...
上传图片
插入图片