添加Timer代码
- (void) createTimer
{
NSTimer *timer = [NSTimer timerWithTimeInterval:3.0 target:self selector:@selector(increaseCurrentPage) userInfo:nil repeats:YES];
self.timer = timer;
//消息循环
NSRunLoop *runloop = [NSRunLoop currentRunLoop];
[runloop addTimer:timer forMode:NSDefaultRunLoopMode];}
[self createTimer]
在viewDidLoad
中调用,当不注释掉[self createTimer]
的时候,
- (void) scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
[self.timer invalidate];
NSLog(@"draggged");
}
这段代码没有响应,不响应断点,只有当[self createTimer]
注释掉之后,才会响应,这是为什么呢
PHP中文网2017-04-17 17:14:30
[runloop addTimer:timer forMode:NSDefaultRunLoopMode];
Changed to:
[runloop addTimer:timer forMode:NSRunLoopCommonModes];
Try it!
怪我咯2017-04-17 17:14:30
I would like to ask【NSTImer sch. . . 】What is the difference from init?