0

我正在做一个项目,我必须创建一个倒数计时器,就像某些食谱应用程序中使用的计时器一样。我的问题是,我该如何创建一个可以从应用程序中的任何视图调用(通过点击自定义状态栏)的计时器类/视图控制器......我相信它不会是一个普通的视图控制器,因为这个控制器必须继续更新 UI 上的计时器标签,即使它被隐藏而不是显示。在 appdelegate 中创建计时器视图并将其隐藏直到它被调用是一个好主意吗?

寻求专业人士的意见!

4

2 回答 2

0

Distinguish model, view, and controller. The time may continue to count, and that might indeed be because the app delegate has an NSTimer. But the timer view does not need to keep updating, or even exist, if it is hidden. If you need to show it, you create it, and it consults the NSTimer, the app delegate, or whatever the central model keeper is, and updates itself.

So it may look as though the same view is appearing in different places in your interface but actually it is a new view instance each time. This could be because it is a new view controller instance. The view controller instance and its view comes into existence when needed and goes back out of existence when not needed, but the timer just keeps on keeping on.

于 2013-04-26T03:04:47.537 回答
0

它可能是一个“普通”的 uiviewcontroller,你只需要添加一个 NSTimer,它会在经过一定时间后调用一些选择器(在这里你可以更新你的自定义栏)。

于 2013-04-26T03:29:53.457 回答