UIViewController 覆盖 UINavigationBar
我有一个包含 2 个项目的 UITabBarController,其中每个项目都指向导航控制器类型的视图控制器。
第二项是我的网络服务的登录页面。
未登录的用户将看到登录页面 -> “LoginViewController”。
如果用户已经登录,则会出现不同的视图 -> “LoggedViewController”。
启动时,在我的 AppDelegate 中,我检查用户是否已经登录或需要登录,然后更改视图。
if (!logged) {
LoginViewController * nextView = [[[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil] autorelease];
NSMutableArray * tabBarRootViews = [[NSMutableArray alloc] initWithArray:self.tabBarController.viewControllers];
[tabBarRootViews replaceObjectAtIndex:1 withObject:nextView];
[self.tabBarController setViewControllers:tabBarRootViews animated:YES];
} else {
// Same if the user is logged only diff view
}
当视图呈现时,它与 UINavigationBar 重叠。 我相信问题是我正在尝试用 UIViewController 替换 UINavigationController,但我无法指出问题所在。
- 知道如何解决吗? (我想同时看到 UITabBar 和 UINavigationBar 以及中间的 UIViewController)
- 这是更改 ViewController 的正确方法吗?我应该使用 PresentModalView 代替吗?
谢谢!
I have a UITabBarController with 2 items, where each item is pointing to a view controller of type Navigation Controller.
The second item is a login page to my web service.
A User that did not logged in will see a login page -> "LoginViewController".
If a user is already logged in, a different view will be there -> "LoggedViewController".
On Startup, in my AppDelegate i am checking if the user already logged or need to login and i change the views.
if (!logged) {
LoginViewController * nextView = [[[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil] autorelease];
NSMutableArray * tabBarRootViews = [[NSMutableArray alloc] initWithArray:self.tabBarController.viewControllers];
[tabBarRootViews replaceObjectAtIndex:1 withObject:nextView];
[self.tabBarController setViewControllers:tabBarRootViews animated:YES];
} else {
// Same if the user is logged only diff view
}
When the view is presented, It overlaps the UINavigationBar.
I believe that the issue is that i am trying to replace a UINavigationController with a UIViewController, but i can't put my finger on the problem.
- Any idea how to solve it? (I want to see both the UITabBar and UINavigationBar and the UIViewController in the middle)
- Is that the correct way to change ViewControllers? Should i Use PresentModalView Instead?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过保持 UINavigationController 不变并根据记录的布尔值推送视图控制器来修复它。
I fixed it by keeping the UINavigationController as is and push a view controller according to the logged boolean.