Code Monkey home page Code Monkey logo

Comments (4)

leonbreedt avatar leonbreedt commented on September 15, 2024

Just as a data point, I set my first date and last date to a year before and year after the current date, respectively.

from objc-timessquare.

DwightEverhart avatar DwightEverhart commented on September 15, 2024

Indeed, this is a serious performance issue, and the time required to display the calendar is proportional to the number of months displayed, since every cell must be created before anything is displayed.

I fixed this problem by adding a +rowHeight class method to TSQCalendarCell, which is overridden in subclasses. Then I changed TSQCalendarView's -tableView:heightForRowAtIndexPath: method to ask the cell's class for the rowHeight, instead of instantiating a cell instance:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    return [[self cellClassForRowAtIndexPath: indexPath] cellHeight];
}

- (Class) cellClassForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    if (indexPath.row == 0 && !self.pinsHeaderToTop) {
        return [self headerCellClass];
    } else {
        return [self rowCellClass];
    }
}

After making these changes, performance has improved significantly, and the time to display the calendar is constant, no matter how many months are displayed, since now only the visible cells are created.

from objc-timessquare.

aleemstreak avatar aleemstreak commented on September 15, 2024

any chance this will get merged into master?

from objc-timessquare.

puls avatar puls commented on September 15, 2024

Thanks again for filing this. More words on performance: http://corner.squareup.com/2013/03/times-square-2.html

from objc-timessquare.

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.