Code Monkey home page Code Monkey logo

Comments (7)

sshiqiao avatar sshiqiao commented on June 11, 2024

你好,这个的确是bug额...
demo中“作品”类别使用的局部刷新,“喜欢列表”使用的是reloaddata,应该统一使用局部刷新。
修改如下:
[wself.data addObjectsFromArray:array];
[wself.tableView reloadData];

改为

[wself.tableView beginUpdates];
[wself.data addObjectsFromArray:array];
NSMutableArray<NSIndexPath *> *indexPaths = [NSMutableArray array];
for(NSInteger row = wself.data.count - array.count; row<wself.data.count; row++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
[indexPaths addObject:indexPath];
}
[wself.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:NO];
[wself.tableView endUpdates];

代码已上传,请查看。

from douyin-ios-objectc.

chengzongxin avatar chengzongxin commented on June 11, 2024

@sshiqiao 谢谢回复

我没看到你新上传的代码,把你说的局部刷新方法替换reloaddata,问题还是没有解决哦

貌似,局部刷新和直接reloaddata,都会释放当前cell,然后再重新加载cell,即使把动画改成NO也是一样的

所以这个问题我试过很多办法都没办法修复

复现步骤:

AwemeListController中,上滑加载更多视频的时候,只有请求,没有更新数据源,所以也不会刷新table,只要请求了接口刷新tableview,bug就会复现了,即使换成局部刷新也还是不行,你可以试试哈

直接替换掉AwemeListController中下面的方法,然后上滑就会出现我说的问题了

=============bug复现代码===============

#pragma load data

  • (void)loadData:(NSInteger)pageIndex pageSize:(NSInteger)pageSize {

    // 2秒模拟网络延迟
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    NSArray *array = [NSArray arrayWithArray:self.data];

      [self.tableView beginUpdates];
      [self.data addObjectsFromArray:array];
      NSMutableArray<NSIndexPath *> *indexPaths = [NSMutableArray array];
      for(NSInteger row = self.data.count - array.count; row<self.data.count; row++) {
          NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
          [indexPaths addObject:indexPath];
      }
      [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:NO];
      [self.tableView endUpdates];
      
      [self.loadMore endLoading];
    

    });
    }

=============bug复现代码===============

from douyin-ios-objectc.

sshiqiao avatar sshiqiao commented on June 11, 2024

不会的,你再试试看,代码上传了。

from douyin-ios-objectc.

chengzongxin avatar chengzongxin commented on June 11, 2024

换成局部刷新还是不行的哦
`

  • (void)loadData:(NSInteger)pageIndex pageSize:(NSInteger)pageSize {

    // 2秒模拟网络延迟
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    NSArray *array = [NSArray arrayWithArray:self.data];

      [self.tableView beginUpdates];
      [self.data addObjectsFromArray:array];
      NSMutableArray<NSIndexPath *> *indexPaths = [NSMutableArray array];
      for(NSInteger row = self.data.count - array.count; row<self.data.count; row++) {
          NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
          [indexPaths addObject:indexPath];
      }
      [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:NO];
      [self.tableView endUpdates];
      
      [self.loadMore endLoading];
    

    });
    }
    `

你把这段代码替换上去,就能看到bug了

from douyin-ios-objectc.

chengzongxin avatar chengzongxin commented on June 11, 2024

@sshiqiao 此外还想提一点建议哈

因为我看到你是用AVPlayerManager单例管理所有的player的播放,暂停,重放等

如果有添加了滑动功能,越到后面滑的越多,单例里面的player就会越来越多,每次播放器播放,暂停什么的,都会遍历所有player,对性能有不必要的开销

如果能在适当的时机,删除playerarray里面的播放器那就很好了

from douyin-ios-objectc.

w819314930 avatar w819314930 commented on June 11, 2024

如何实现下拉加载功能。。大佬

from douyin-ios-objectc.

chengzongxin avatar chengzongxin commented on June 11, 2024

如何实现下拉加载功能。。大佬

加个MJRefresh不就可以了

from douyin-ios-objectc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.