ios cell滚动

2017-10-10  本文已影响0人  oc123

本文旨在收集开发过程中tableView的各种用法,并将其分享给有需要的人;
用法一:常见的中奖名单滚动效果
示例代码链接:https://github.com/wangshuixin/PrizeListAnimationDemo.git
实现效果主要代码代码如下:

-(void)getApplyList{
    __block int timeout = 0; //计时
    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
    dispatch_source_set_timer(timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
    dispatch_source_set_event_handler(timer, ^{
        if(timeout < 0)
        { //计时结束,关闭
            dispatch_source_cancel(timer);
            dispatch_async(dispatch_get_main_queue(), ^{
                
            });
        }
        else
        {
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [_data addObject:@""];//data为数据数组
                NSIndexPath *indexPath = [NSIndexPath indexPathForRow:_data.count - 1 inSection:0];//cell增加的位置
                [self.applyListTV insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];//在indexPath处增加cell,self.applyListTV 为tableView
                [self.applyListTV selectRowAtIndexPath:indexPath animated:YES  scrollPosition:UITableViewScrollPositionBottom];//滚动至增加的cell处
                
            });
            
            timeout++;
            
        }
    });
    dispatch_resume(timer);
}

用法二:待收集
如果本文对你有帮助,请不吝点赞,你的支持是我不断分享的动力;
荆轲刺秦王!

上一篇下一篇

猜你喜欢

热点阅读