What does the iOS error “request for rect of invalid section” mean?

前端 未结 3 649
猫巷女王i
猫巷女王i 2021-01-12 02:07

Google reveals no posts at all for this error message. I\'m getting it in iOS 5 trying to update a UITableView. While the exact code is a bit tortured, this is what I\'m doi

相关标签:
3条回答
  • 2021-01-12 02:53

    Leaving this here as well as a separate possible cause.

    If you are trying to delete rows in the moveRowAtIndexPath: method you will get the same crash. You have to wait until it finishes to do that.

    0 讨论(0)
  • 2021-01-12 02:54

    Looks like your code is trying to work with a section of your table that does not exist.

    Since NSArrays are zero-indexed, the index value of count will be outside the bounds of the array. You should subtract one from the count when using indexSetWithIndex: here:

    [table insertSections: [NSIndexSet indexSetWithIndex: [sections count]-1] 
                                        withRowAnimation: UITableViewRowAnimationNone];
    
    0 讨论(0)
  • 2021-01-12 03:01

    Posting as answer in case it happens to somebody else as well.

    I found the issue looking at jonkroll's answer, but in my case this happened because I was calling the same method twice and that method removed a row from the table view.

    0 讨论(0)
提交回复
热议问题