nstimer注意事项

当nstimer在主线程创建时,当滑动时,系统为了更好的处理UI事件,会暂停timer,解决办法就是改变timer的mode,不使用缺省的NSDefaultRunLoopMode,而是改用NSRunLoopCommonModes

NSTimer *timer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(timer:) userInfo:nil repeats:YES];

[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];

posted @ 2017-05-12 12:04  柳仙慧子  阅读(127)  评论(0编辑  收藏  举报