首页 > 其他 > 详细

定时器注意

时间:2016-05-11 13:26:57      阅读:130      评论:0      收藏:0      [点我收藏+]

1.注意要将定时器加入RunLoop中去(避免其他事件暂停了定时器事件)

        _timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerCountDown) userInfo:nil repeats:YES];
        [[NSRunLoop mainRunLoop] addTimer:_timer forMode:UITrackingRunLoopMode];

2.在界面小时,记得销毁定时器,且置为nil

    [_timer invalidate];
    _timer = nil;

 

定时器注意

原文:http://www.cnblogs.com/shpyoucan/p/5481302.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!