返回“主”应用程序关闭(然后启动)时查看控制器

发布于 2024-12-10 11:45:42 字数 258 浏览 5 评论 0原文

我有一个带有 2 个视图控制器的项目,基本上是天气应用程序或股票。应用程序使用故事板并通过 segues 在视图之间切换。 第一个视图是“主”视图,第二个视图是应用内设置。

所以我进入“设置”,然后按主页按钮。

我需要下次启动应用程序时位于主视图中,而不是在设置中。应用程序进入后台后(按下主页按钮时),如何从第二个 vc 切换到第一个 vc?

我需要在某处使用“performSegueWithIdentifier:”吗?我可以从应用程序委托执行它吗?

I have a project with 2 view controllers, basically as Weather app or Stocks. App uses storyboard and switching between views with segues.
1-st view is "main", 2-nd is in-app settings.

So I go to "settings" and then press home button.

I need when I launch app next time to be in main view, not in settings. How do I switch from 2-nd vc to 1-st after app goes to background (when home button is pressed)?

Do I need to use "performSegueWithIdentifier:" somewhere? Can I execute it from app delegate?

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

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

发布评论

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

评论(1

孤千羽 2024-12-17 11:45:42

在 AppDelegate 的 applicationWillResignActive 中进行切换。这在您的应用程序变为非活动状态之前的某个时刻被调用。

Make the switch in your AppDelegate's applicationWillResignActive. This is called a moment before your app becomes inactive.

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