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];

原文地址:https://www.cnblogs.com/liuting-1204/p/6844916.html