我正在开发一个应用程序,我有一个登录/注销过程。当用户单击退出按钮时,我希望将用户带到主屏幕。为此,我在应用程序委托中创建了以下方法:
- (void) restartAppWhenLogOut{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
WelcomViewController *welcomeViewController = [[WelcomViewController alloc]init];
self.navController = [[UINavigationController alloc] initWithRootViewController:welcomeViewController];
[self.window setRootViewController:navController];
[self.window makeKeyAndVisible];
}
当用户单击“注销”按钮时,我称之为:
[[UIApplication sharedApplication].delegate restartAppWhenLogOut];
它工作正常,除了一件事。UINavigationBar 比它应该的要小!这是它的外观截图:
UINavigationBar 应该填充一条小黑线...
知道为什么会这样吗?
========================================编辑========== ==============================
David M.
我删除了一条评论中告诉我要做的新窗口创建,但它仍然失败:
[self.navController popToRootViewControllerAnimated:NO];
WelcomViewController *welcomeViewController = [[WelcomViewController alloc]init];
self.navController = [[UINavigationController alloc] initWithRootViewController:welcomeViewController];
[self.window setRootViewController:navController];