runloop

tatableview与轮播图滚动冲突问题解决方案

一、将NSTimer加入到主runloop中并设置runloop 的mode为NSRunLoopCommonModes或UITrackingRunLoopMode

① [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];

 [[NSRunLoop mainRunLoop] addTimer:timer forMode:UITrackingRunLoopMode];

二、将NSTimer加入到子线程中,并开启子线程runloop

    dispatch_async(dispatch_get_global_queue(0, 0), ^{

        NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:self.autoScrollTimeInterval target:self selector:@selector(automaticScroll) userInfo:nil repeats:YES];

        _timer = timer;

        [[NSRunLoop currentRunLoop] run];

    });

 

posted on 2017-08-22 15:57  小艾的博客  阅读(115)  评论(0编辑  收藏  举报

导航