Skip to content

exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN #17

@mralghazali

Description

@mralghazali

First thing first I wanna say thank you for making this library, this is really a great work.

But unfortunately I just found an issue. I made a 3-header-rows and 1-header-column table and sometimes when I ran my project, it becomes crash with following error:

2015-02-12 12:35:23.981 mommychi[578:121987] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [2.5 nan]'
*** First throw call stack:
(0x2b7ac5f7 0x392fac77 0x2b7ac53d 0x2e6721cf 0x2e6720d3 0x2e672065 0x2ec4afe3 0x1c48dd 0x1c2b69 0x2ec4e19f 0x2e679f65 0x2e675951 0x2e6757d9 0x2e6751c7 0x2e674fd1 0x2e66eedd 0x2b773015 0x2b7706f9 0x2b770afb 0x2b6bdb31 0x2b6bd943 0x32a72051 0x2ecaff21 0x59ef5 0x39896aaf)
libc++abi.dylib: terminating with uncaught exception of type NSException

Recently I realized that the error comes from MMSpreadsheetView.m, particularly at this line:

CGFloat indicatorOffsetY = collectionView.contentOffset.y / (contentSize.height - collectionViewFrame.size.height) * (scrollIndicator.frame.size.height - indicatorHeight);

The problem is (contentSize.height - collectionViewFrame.size.height) comes to zero.

Then I edited that line to:
CGFloat divider = (contentSize.height - collectionViewFrame.size.height > 0) ? (contentSize.height - collectionViewFrame.size.height) : 0.1;
CGFloat indicatorOffsetY = collectionView.contentOffset.y / divider * (scrollIndicator.frame.size.height - indicatorHeight);

I don't really understand what have I edited, but it become works, the error's gone.
Can you enlighten me about this issue? I hope there will be no another problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions