iOS tableView滑动到区头的时候

本文探讨了UITableView在实现区头跟随滑动时可能导致的卡顿问题,并提供了一种解决方案:通过更改tableView样式为Grouped样式来避免使用scrollView滑动判断。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

UITableView的区头跟着滑动有可能会造成滑动到头部的时候回卡顿,如果你写了这样一段话,那么,很有可能是它造成的

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{

    

    

    if (scrollView == self.tableView) {

     

        [[NSNotificationCenter defaultCenter] postNotificationName:kBackScroll object:self userInfo:@{@"noticification":@(scrollView.contentOffset.y)}];

        

        CGFloat contentHeight = kRadio(260);

        

        if (scrollView.contentOffset.y <= contentHeight && scrollView.contentOffset.y > 0) {

            scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);

            

        }else if(scrollView.contentOffset.y >= contentHeight){

            

            scrollView.contentInset = UIEdgeInsetsMake(-contentHeight, 0, 0, 0);

            

        }

        

    }

    

}


解决方法:   将tableView的样式改为Grouded的,不再使用scrollView的滑动判断


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值