Giter Site home page Giter Site logo

您好,当放在cell中时,上下滚动回来时弹幕从头开始滚动,怎么能保持之前的状态? about zblivebarrage HOT 7 OPEN

PPLLock avatar PPLLock commented on August 22, 2024
您好,当放在cell中时,上下滚动回来时弹幕从头开始滚动,怎么能保持之前的状态?

from zblivebarrage.

Comments (7)

zhmbo avatar zhmbo commented on August 22, 2024

您好,当放在cell中时,上下滚动回来时弹幕从头开始滚动,怎么能保持之前的状态?感谢,已经去掉了cell复用

我理解你的意思是每个cell 都有一个 ZBLiveBarrage View,这种情况可以在 cell 离开屏幕是调用 ZBLiveBarrage 里所有 cell 的暂停,等 cell 进入屏幕是在调用开始

from zblivebarrage.

PPLLock avatar PPLLock commented on August 22, 2024

感谢您的回复,我的目的是想要让tableView在上下滚动时不影响弹幕,往上滚动再滚动回来,弹幕一直是继续走,离开屏幕不暂停也不重头开始,而是继续当前横向移动,再次感谢开源这么优秀的框架

from zblivebarrage.

zhmbo avatar zhmbo commented on August 22, 2024

感谢您的回复,我的目的是想要让tableView在上下滚动时不影响弹幕,往上滚动再滚动回来,弹幕一直是继续走,离开屏幕不暂停也不重头开始,而是继续当前横向移动,再次感谢开源这么优秀的框架

明白你的意思了,你的需求cell的重用机制会把动画吞掉,即使你不重用也只是重复创建新的cell,不但效果没有实现反而会消耗内存降低帧数,解决办法就是自己创建一个缓存池将cell存起来,核心代码如下:

实测这种实现也不会造成卡顿

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *cellid = [NSString stringWithFormat:@"ZBTestTableViewCell-%ld-%ld",indexPath.section,indexPath.row];
    NSArray *objects = [self.cellArray filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"reuseIdentifier = %@",cellid]];
    if (objects.count > 0) {
        return objects.firstObject;
    }else {
        ZBTestTableViewCell *cell = [[ZBTestTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid];
        [self.cellArray addObject:cell];
        return cell;
    }
}

这里可以把 cellArray 优化剥离出来一个类,具体你自己动手实现一下

from zblivebarrage.

PPLLock avatar PPLLock commented on August 22, 2024

感谢您的回复和解答,这个问题我解决了,现在遇到另一个问题,当我push到另一个页面再pop返回时,我想让弹幕进行之前的状态,但是返回后都是重新开始,我调试发现oldBarrage.layer.presentationLayer frame,获取到的rect.origin.x的值都为负数且刚好是负orldBarrage的宽度,这个一直不知道该怎么处理,应该是presentationLayer在离开当前屏幕后就获取不到frame了

from zblivebarrage.

PPLLock avatar PPLLock commented on August 22, 2024

也不是进行之前的状态,就是让它在后台也能持续在走,返回时坐标也按动画的速度进行frame更新

from zblivebarrage.

zhmbo avatar zhmbo commented on August 22, 2024

也不是进行之前的状态,就是让它在后台也能持续在走,返回时坐标也按动画的速度进行frame更新

这个解决办法,就是不能用系统的push或者present,用 viewController的 addChildViewController,并添加view,然后在新的viewController控制view的动画模拟push动画效果,这样原来viewController上的view的layer才不会被kill,系统的push或者present这两个方法都会结束当前 layer 的动画

from zblivebarrage.

PPLLock avatar PPLLock commented on August 22, 2024

好的,确实是非常好的解决办法,谢谢您,我这边再调整一下

from zblivebarrage.

Related Issues (1)

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.