我希望在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];
不知道問題在哪裡~
從網上搜來的,
[[UIApplication sharedApplication] keyWindow].rootViewController = revealController;
設置另一個root view controller,看看能實現不?