【问题标题】:NSTimer how to disable while timer is still active?NSTimer 如何在计时器仍处于活动状态时禁用?
【发布时间】:2012-05-18 20:52:02
【问题描述】:

我已经创建了一个计时器,

   self.scanTimer = [NSTimer scheduledTimerWithTimeInterval:TIMEOUT_SECONDS target:self selector:@selector(meInterrupted:) userInfo:nil repeats:NO];

在我的代码中的某个时间点,我觉得在超时发生之前禁用它,以便不调用 meInterrupted?。如何做到这一点?

【问题讨论】:

    标签: iphone objective-c ios4 ios5


    【解决方案1】:

    只需调用 [self.scanTimer invalidate];如果在计时器触发之前调用它,这将使计时器永远不会触发。

    【讨论】:

    • Ya das ist gut.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-10
    • 1970-01-01
    • 1970-01-01
    • 2012-08-31
    • 1970-01-01
    • 2010-11-10
    • 2018-06-28
    相关资源
    最近更新 更多