如何在iPhone应用程序中使用睡眠

发布于 2024-09-05 06:30:55 字数 360 浏览 4 评论 0原文

我习惯在我的应用程序中加载默认图像。所以我已经设定了,

      Sleep(3); in my delegate.m class.

但有时需要超过6到7分钟。所以我只想显示图像 3 秒,然后根据我的要求进入我的应用程序。

哪一种是最好的方法?

     Sleep(3) or [NSThread sleepForTimeInterval:3.0] or something else; 

我必须只显示图像 3 秒。请解释一下。 (注意:我只在我的 delegate 类中声明了 setter 和 getter 方法。)

请解释一下。

I have used to loading a default image in my appication. So i have set to,

      Sleep(3); in my delegate.m class.

But sometimes it will take more than 6 to 7 minutes. So i want to display the image 3 seconds only and then it goes to my appilcation based on my requirements.

Which one is best way to do that?

     Sleep(3) or [NSThread sleepForTimeInterval:3.0] or something else; 

And i must display the image 3 seconds only. Please explain me.
(Note: And I declared setter and getter methods only in my deleagte class.)

Please explain me.

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

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

发布评论

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

评论(2

半边脸i 2024-09-12 06:30:55

正如 Rob 指出的那样,苹果强烈建议不要使用启动画面,除非它隐藏了一些必要的幕后过程(例如加载游戏图形)。强烈建议不要使用启动画面,以至于有些人声称他们的应用程序因使用不必要的启动画面而被拒绝。

default.png 的存在并不是为了创建启动画面。相反,它的存在是为了让您产生一种错觉,即您的初始视图加载速度比实际情况更快。您应该使用它来提供初始视图的图像,以便最终用户可以开始认知地适应界面。当他们将自己定位到界面并移动手指触摸界面时,界面就已上线。

为什么?因为 iPhone 应用程序应该是快进快出。人们不会像桌面一样坐在办公桌前使用它们。人们在旅途中使用它。有时他们在谈话中使用它们。

我告诉我的客户在散步、骑健身车等以及面对面和电话交谈时测试他们的应用程序的可用性(游戏除外)。在这种情况下,三秒的暂停是一件大事,而且非常引人注目,特别是如果该应用程序是一个实用的应用程序。想象一下,如果每次打开“联系人”应用程序时,您都必须暂停三秒钟才能看到 Apple 启动屏幕。你很快就会生气。

这里的关键是不必要的启动屏幕不会为用户增加任何价值。软件发行商为了自己的唯一利益而蚕食最终用户的时间,从而建立品牌认知度是一种自私行为。用户每次使用该应用程序都会浪费三秒钟的时间,这样一来,时间就会增加。 (根据我的经验,这也会让用户感觉整个应用程序又慢又笨重。)

但是,如果您确实想搬起石头砸自己的脚,或者您的客户在启动画面上一心一意,那么您可以这样做this:

启动屏幕会一直显示,直到第一个视图加载,因此您可以延迟第一个视图的加载。在应用程序委托 applicationDidFinishLaunching: 方法中,删除将第一个视图加载到窗口中的所有代码。将其替换为 NSTimer。将加载第一个视图的代码放入计时器的 fire 方法中。

通过该设置,应用程序将在启动时显示default.png,当它到达applicationDidFinishLaunching:时,从最终用户的角度来看,它会显示为暂停,因为不会出现任何视图来替换default.png。

您应该注意,应用程序的标准启动时间是 3-5 秒。因此,您可能无需执行任何操作即可显示闪屏 3 秒。它可能会自动发生。

As Rob noted, Apple strongly recommends against a splash screen unless it hides some necessary behind the scenes process (like loading game graphics.) It is so strongly discouraged that some people have claimed that their apps have been rejected for using an unnecessary splash screen.

The default.png doesn't exist to create a splash screen. Instead it exist to allow you to create the illusion that your initial view loads faster than it does. You supposed to use it to provide an image of your initial view so that the enduser can begin to cognitively orient themselves to the interface. By the time they have oriented themselves to the interface and moved their finger to touch the interface, it is live.

Why? Because iPhone apps are supposed be quick in, quick out. People don't sit down to use them at a desk like a desktop. People use then on the go. Sometimes they use them in the middle of a conversation.

I tell my clients to test out the usability of their apps (except for games) while walking, riding an exercise bike etc as well as in the middle of a face-to-face and phone conversation. In those circumstances, a three second pause is a big deal and very noticeable especially if the app is a practical app. Imagine if every time you opened the Contact app you had to pause three seconds to see an Apple splash screen. You would get peeved in a hurry.

The key thing here is that an unnecessary splash screen doesn't add any value for the user. It is a selfish act on the part of the software publisher to eat the end users time so that the publisher can build brand recognition for the sole benefit of the publisher. Wasting three seconds of the users time every time they use the app adds up in a hurry. (In my experience, it also makes the user perceive that the overall app is slow and clunky.)

However, if you do want to shoot yourself in the foot or if you have a client hell bent on a splash screen, you do it like this:

The splash screen appears until the first view loads so you delay the loading of the first view. In the app delegates applicationDidFinishLaunching: method, remove all the code that loads the first view into the window. Replace it with a NSTimer. Put the code to load the first view in the timer's fire method.

With that setup the app will display the default.png as it launches, when it gets to applicationDidFinishLaunching:it will appear to pause from the end users perspective because no view will appear to replace the default.png.

You should note that the standard launch time for an app is 3-5 seconds. So you may not have to do anything to show the splash screen for 3 seconds. It might happen automatically.

像极了他 2024-09-12 06:30:55

Apple 强烈建议不要这样做(以这种方式使用睡眠),特别是在显示启动屏幕的情况下。

最好的办法是创建一个类似于 Default.png< 的视图/code> 文件,然后将其作为第一个 NIB.. 然后您可以设置一个 NSTimer 来转换(如果需要的话可以使用动画)到您的主视图/窗口/控制器。

Apple strictly recommends against this (using sleep in this way), especially in the scenario of showing a splash screen.

The best thing to do is create a view that looks like your Default.png file, then have that be the first NIB.. you could then set an NSTimer to transition (with animation if you want) to your main view/window/controller.

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