GithubHelp home page GithubHelp logo

collectionviewdemo's Introduction

performBatchUpdates 崩溃测试

insertItems或者reloadSections时如果和数据的修改不一致就会导致崩溃,如下

        self.collectionView.performBatchUpdates {
            // 在数据源中插入新的数据
            self.data[0].append("\(self.data[0].count + 1)")
            //  self.data[1].append("\(self.data[1].count + 1)")
            
            // 插入新的 cell
            let indexPath1 = IndexPath(item: self.data[0].count - 1, section: 0)
            let indexPath2 = IndexPath(item: self.data[1].count - 1, section: 1)
            
            self.collectionView.insertItems(at: [indexPath1, indexPath2])
        }

如果你想要在 UICollectionView 中插入新的行而不是整个重新加载某个 section,建议使用 insertItems 方法。这可以提供更好的用户交互效果,而reloadSections会导致整个 section 重新加载,从而有闪烁的问题。

collectionviewdemo's People

Contributors

dacaiguoguo avatar

Watchers

 avatar

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.