ios - 如何停止 NStimer 事件?

标签 ios objective-c iphone nstimer

Possible Duplicate:
NSTimer doesn't stop

在我的应用程序中,我使用 NStimer 每 3 秒调用一次动画函数。我想停止这个计时器并在计时器仍在运行时调用另一个事件。这可能吗?

最佳答案

@interface
    NSTimer *autoTimer;

@implementation

// Start timer
    autoTimer = [NSTimer scheduledTimerWithTimeInterval:(3.0)
        target:self 
        selector:@selector(autoTimerFired:) 
        userInfo:nil 
        repeats:YES];

// Stop timer:
    [autoTimer invalidate];
    autoTimer = nil;

关于ios - 如何停止 NStimer 事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1429571/

相关文章:

ios - iphone 应用程序中的内存泄漏 sqlite3MemMalloc

iOS AVAudioPlayer 再次播放声音

iphone - 如何正确使用ABPersonViewController 和ABPeoplePickerNavigationController 来查看联系人信息?

iphone - 在旋转时放置和移动 View (UIView)

objective-c - iOS 4 上的推送通知如何显示?

ios - SWRevealViewController : Make Starting Background View Grey with custom animations

iOS : How do I slide a list item to expose commands (w/storyboards)

iphone - 在 iOS 中访问设备控制台日志的 Objective C 代码

ios - 将一个 NSString 常量分配给另一个

iOS 交互通知所有 Action 不可见