如何加载新视图并从那里开始导航?

发布于 2024-09-06 11:48:30 字数 597 浏览 2 评论 0原文

我已经在谷歌上搜索了好几天了,我正在绞尽脑汁试图让它发挥作用。在我的应用程序中,加载的第一个视图是具有登录和注册按钮的视图。按登录按钮

- (IBAction)login:(UIButton *)sender {
  LoginViewController *loginView = [[LoginViewController alloc] initWithNibName:@"LoginView" bundle:nil];
  [self presentModalViewController:loginView animated:YES];
  [loginView release];
}

会显示一个登录表单。用户登录后,我想关闭模态视图(我已经实现了),然后用全新的视图/视图控制器替换带有登录和注册按钮的视图,并拥有那个是 UINavigationController 的根控制器。然后从那里继续。

我怎样才能实现这个?谢谢!

编辑:我最终从一个基于选项卡栏的应用程序开始,每个选项卡都有一个导航控制器(这解决了我的其他问题),并在处理应用程序的主要部分后处理登录部分。启动后,我将检查用户是否已登录,如果没有,则以模态方式显示登录视图,但不显示动画。

I've been googling this for days, and I'm pulling my hair out trying to get this to work. In my app, the very first view that loads is a view that has a login and signup button. Pressing the login button calls

- (IBAction)login:(UIButton *)sender {
  LoginViewController *loginView = [[LoginViewController alloc] initWithNibName:@"LoginView" bundle:nil];
  [self presentModalViewController:loginView animated:YES];
  [loginView release];
}

Which presents a login form. After the user logs in, I would like to dismiss the modal view (which I already have implemented) and then replace the view with the login and signup buttons with an entirely new view/view controller and have that be the root controller for UINavigationController. And go on from there.

How can I implement this? Thanks!

EDIT: I ended up starting off with a tab bar-based app with a navigation controller for each tab (which solved my other problems) and dealing with the login part after I work on the main part of the app. Upon launch, I'm going to check if the user is logged in and if not, present the login view modally but with no animation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迷爱 2024-09-13 11:48:30

我刚刚重新阅读了你的问题,我错过了关于它是导航控制器中的根控制器的部分。也许你可以更换导航控制器?或者在您真正需要之前甚至不使用导航控制器?

I just re-read your question and I'd missed the part about it being the root controller in your navigation controller. Perhaps you could replace the navigation controller? Or perhaps not even use a navigation controller until you actually need it?

梦醒时光 2024-09-13 11:48:30

为什么不在登录 root 后创建视图,而是在应用程序启动时调用 [self.navigationItem setHidesBackButton:YES];,然后推送您的登录视图(非动画)。然后呈现您的模态视图控制器,登录完成后,关闭模态视图控制器并在带有登录/注册按钮的视图上调用 [self.navigationController popToRootViewControllerAnimated:NO];

Why not make the view after login root, but on app startup call [self.navigationItem setHidesBackButton:YES];, and then push your login view (not animated). Then present your modal view controller, and when the login is finished, dismiss the modal view controller and call [self.navigationController popToRootViewControllerAnimated:NO]; on the view with the login/signup buttons.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文