ListView strikes again, ugggggggg (iOS)

RaymondKellyRaymondKelly USMember ✭✭✭

I have a chat messaging app. I need to scroll to the bottom with each chat message. I get constant crashes when calling ScrollTo.

NSInternalInconsistencyException Reason: table view row height must not be negative - provided height for index path ( {length = 2, path = 0 - 10}) is -1.000000

I think the issue is that I am showing complex FormattedStrings and uneven rows in the table cell and it takes a second to animate (the drop down animation). So when ScrollTo is called inside the observable collection CollectionChanged, it crashes with the above error since the animation is not complete yet. And there does not seem to be any way to disable animations on iOS (Android works fine). I have tried both the native ListVIew and a custom renderer with the same results. Can anyone assist? Thank you.


  • RaymondKellyRaymondKelly USMember ✭✭✭

    I think I have found the crash. Using a custom renderer I found:
    public override nfloat EstimatedHeight(UITableView tableView, NSIndexPath indexPath) { return this.cachedHeights.ContainsKey(indexPath.Row) ? (nfloat)this.cachedHeights[indexPath.Row] : 200; }

    If the return == 1, then the crash will occur. I replaced it with this:

    public override nfloat EstimatedHeight(UITableView tableView, NSIndexPath indexPath) { nfloat es = this.cachedHeights.ContainsKey(indexPath.Row) ? (nfloat)this.cachedHeights[indexPath.Row] : 200; if(es < 2) { es = 200; } return es; }

    I dont know what the deal is or if this is even the right thing to do, but it stopped the crashes. Thoughts on whats going on?

Sign In or Register to comment.