如何在 iPhone 4 上实现频闪灯

发布于 2024-09-28 09:27:01 字数 158 浏览 1 评论 0原文

我想在我的 iphone 4 上实现频闪灯,我已经有打开和关闭 LED 的代码。

我想我应该使用 NSTimer 来重复打开和关闭灯的方法,我还想我会使用 UISlider 来改变闪光灯闪烁的速率。

我只需要知道实现频闪的最佳方法是什么。我真的很感激我能得到的任何帮助。

I would like to implement a strobe light on my iphone 4 I already have the code to turn on and off the LED.

I figure I should use an NSTimer to repeat the method that turn the light on and off, also i figure i would use a UISlider to change the rate at which the strobe flashes.

I just need to know what the best way to implement the strobe would be. I'd really appreciate any help I could get on this.

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

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

发布评论

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

评论(2

心在旅行 2024-10-05 09:27:01

(不知道为什么有人会否决这个问题——如果含糊的话,这是完全合理的问题)。

听起来你的做法很合理;以这种方式使用 NSTimer 将是尽可能被动的,而 UISlider 无疑是一个合理的控件。

(No idea why anyone would vote this down -- perfectly reasonable question, if vague).

It sounds like your approach is pretty reasonable; using an NSTimer in that fashion will be about as passive as you can get and a UISlider is certainly a reasonable control.

脸赞 2024-10-05 09:27:01

这是一个用人类语言/伪语言描述的解决方案:

创建一个方法,使用设置计时器间隔的参数(浮点)来初始化 NSTimer。

用户与滑块的交互应停止计时器,并使用滑块的新值对其进行初始化。

简单的。只需确保在 IB 中将滑块的最大值和最小值设置为合理的值即可。首先将其设置为高(例如 1 秒)作为概念证明。

Here's a solution in human words/pseudo:

Create a method that inits NSTimer with a parameter (float) setting the timer interval.

Users interaction with the slider should stop the timer, and init it with the sliders new value.

Simple. Just make sure that you set the max and min values of the slider to something reasonable in IB. At first set it high (like 1 second) as proof of concept.

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