使用“后退"按钮时,每次页面加载时,计时器的减量都会有所不同 [英] Timer decrement gets varied for each page load when using back button
本文介绍了使用“后退"按钮时,每次页面加载时,计时器的减量都会有所不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我之前的问题中每次页面加载时,计时器的减量都会有所不同当我使用"Invalidate"和"Release"时,代码运行良好.但是,当我使用后退按钮时,会重复同样的问题.而且我也需要停止选项.
In my previous question Timer decrement gets varied for each page load I got the code working well when I used "Invalidate" and "Release". But when i use a back button the same problem repeats. And i need a stop option too..
-(IBAction)back:(id)sender
{
[self dismissModalViewControllerAnimated:YES];
}
-(IBAction)stop:(id)sender
{
[theTimer invalidate];
[theTimer release];
}
这是我在这里使用的代码,但是效果不佳.
this is the code i used here but not working well.
推荐答案
尝试以这种方式使用它..
Try using it in this way..
if ([theTimer isValid]) {
[theTimer invalidate];
theTimer=nil;
}
并确保您的方法已被调用.
And make sure your method is been called.
这篇关于使用“后退"按钮时,每次页面加载时,计时器的减量都会有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文