仅将 UIView 添加为首次运行视图

发布于 2024-09-28 21:13:59 字数 141 浏览 1 评论 0原文

我想向我的应用程序添加一个欢迎视图,其中描述了说明等。

我希望该视图仅在应用程序首次启动时出现一次...然后在后续启动时转到我的应用程序的主视图...这是一个导航控制器。

跟踪发布/实施这个想法的最佳方法是什么?

谢谢。

I would like to add a Welcome view to my app which describes the instructions etc.

I would like this to appear only once when the app is first launched... then with subsequent launches go to my app's main view... which is a navigation controller.

What is the best way to track launches/ implement this idea?

Thanks.

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

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

发布评论

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

评论(3

荒岛晴空 2024-10-05 21:14:00

在导航控制器的根控制器(通常作为第一个可见的视图控制器)中,使用 presentModalViewController:animated: 的初始指令激活模态控制器。

您可能想从 viewWillAppear: 中调用它。不要对模态视图控制器的呈现进行动画处理(否则您会看到下面的内容),但在关闭它时进行动画处理 - 它看起来非常优雅。

使用UserDefaults来存储已经显示的信息,并且不再显示。

In your root controller of a navigation controller (the view controller that is normally visible as first one), activate a modal controller with those initial instructions with presentModalViewController:animated:.

You probably want to call it from within viewWillAppear:. Do not animate presenting of modal view controller (otherwise you see what's below), but animate when dismissing it - it looks really elegant.

Use UserDefaults to store the information that it had already been shown, and do not show it anymore.

春夜浅 2024-10-05 21:14:00

NSUserDefault 正是为此类事情而设计的。

NSUserDefault is made exactly for these kind of things.

终止放荡 2024-10-05 21:14:00

我同意 JustSid 的观点。在我的应用程序中,我为此用途设置了一个 NSUserDefault 值,然后在 viewDidLoad 时将其关闭。该应用程序会检查该值,但除非该应用程序已卸载,否则不会触发该消息。

I would agree with JustSid. In my app, I set a NSUserDefault value for that use and then turned it off when the viewDidLoad. The app checks for the value but, unless the app is uninstalled, will not fire the message.

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