拖动UITableView时,NSTimer暂停

1、
    CFRunLoopRef runLoop = CFRunLoopGetCurrent();
    CFRunLoopTimerContext context = {0, NULL, NULL, NULL, NULL};
    CFRunLoopTimerRef timer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent(), 0.02, 0, 0, &myCFTimerCallback, &context);
    CFRunLoopAddTimer(runLoop, timer, kCFRunLoopCommonModes);


2、
    NSTimer *updateTimer = [NSTimer scheduledTimerWithTimeInterval:0.02 target:self selector:@selector(updatePosition) userInfo:Nil repeats:YES];
    NSRunLoop *mainRunLoop=[NSRunLoop currentRunLoop];
    [mainRunLoop addTimer:updateTimer forMode:NSRunLoopCommonModes];

猜你喜欢

转载自skyfree666.iteye.com/blog/2019086