我想如果按下一个按钮计时器至极开始。 定时器运行时,它不可能再次按下按钮。和警报将显示.. 有你的想法如何实现的呢? 坦克你!backcounting定时器
-6
A
回答
1
创建NSTimer在第一时间按下按钮,并在定时器是有效的,不允许的动作发生,并弹出您的警报。
Store中的NSTimer在对象上的属性。
接口:
@property (strong, nonatomic) NSTimer *timer;
实现:
- (IBAction)buttonClicked:(id)sender
{
if(self.timer == nil || ![self.timer isValid]) {
// Allow the action (set the timer interval to what suits your needs)
self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 invocation:nil repeats:NO];
// DO THE ACTION HERE!
NSLog(@"You can do it this time!");
} else {
// Deny the action (perhaps popup an alert)
NSLog(@"Can't do that yet!");
}
}
+0
它的工作真的很棒非常感谢你的快速答案! – 2013-02-10 23:06:04
+0
@CarstenGraf非常欢迎您。 – Kekoa 2013-02-10 23:07:28
相关问题
- 1. STM32F7定时器触发器定时器
- 2. POSIX定时器 - 有多个定时器
- 3. jquery定时器vs javascript定时器?
- 4. 定时器在另一个定时器
- 5. WPF定时器像C#定时器
- 6. 定时器内的Arduino定时器
- 7. jqgalscroll定时器
- 8. string.Format定时器?
- 9. 定时器Javascript
- 10. 定时器(winforms)
- 11. 由定时器
- 12. 定时器IllegalArgumentException
- 13. STM32F10X定时器
- 14. AlarmManager定时器
- 15. window.location.href +定时器
- 16. UIScrollView定时器
- 17. simple_html_dom定时器?
- 18. 定时器
- 19. javascript定时器
- 20. 比较定时器和调度器定时器
- 21. iPhone定时器选择器
- 22. WPF定时器倒计时
- 23. jquery定时器或倒数计时器
- 24. 从mysql的倒计时器定时器
- 25. 定时器麻烦。 。
- 26. 定时器在Xamarin.forms
- 27. 定时器在UITableViews
- 28. Android的 - 定时器
- 29. 定时器,刷新
- 30. ASP.net VB定时器
你需要做一些自己的研究的第一个。 Stackoverflow不是让人们为自己工作的地方。你也应该尝试,以确保您的文章具有正确的语法(如正确的首都,拼写和文章)。 – 2013-02-10 23:11:43
抱歉,我来自德国,这是我的第一篇文章。我是新来的,下一次我会变得更好! – 2013-02-10 23:15:37