OGeek|极客世界-中国程序员成长平台

标题: ios - UINavigationBar 比它必须要小 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 09:46
标题: ios - UINavigationBar 比它必须要小

我正在开发一个应用程序,我有一个登录/退出流程。当用户单击退出按钮时,我希望将用户带到主屏幕。为此,我在应用委托(delegate)中创建了以下方法:

- (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 比它应该的要小!这是它的外观截图:

enter image description here

UINavigationBar 应该填充一条小黑线...

知道为什么会这样吗?

========================================编辑======= =================================

我删除了新窗口的创建,因为 David M. 在一条评论中告诉我这样做,但它仍然失败:

[self.navController popToRootViewControllerAnimated:NO];
WelcomViewController *welcomeViewController = [[WelcomViewController alloc]init];
self.navController = [[UINavigationController alloc] initWithRootViewController:welcomeViewController];
[self.window setRootViewController:navController];



Best Answer-推荐答案


我试图找出错误..但没有发现..所以,我建议您尝试手动设置导航栏..

关于ios - UINavigationBar 比它必须要小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15481520/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4