如何在 iPhone 4 上实现频闪灯
我想在我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(不知道为什么有人会否决这个问题——如果含糊的话,这是完全合理的问题)。
听起来你的做法很合理;以这种方式使用 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 aUISlider
is certainly a reasonable control.这是一个用人类语言/伪语言描述的解决方案:
创建一个方法,使用设置计时器间隔的参数(浮点)来初始化 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.