UITableView section index related crashes under iOS 7

后端 未结 4 1647
感动是毒
感动是毒 2021-02-15 06:33

I have a simple section index for a table view that appears fine for the first time but then crashes if certain kinds of interaction happens that force a redraw of the section i

相关标签:
4条回答
  • 2021-02-15 07:10

    It's been fixed in the 7.1 beta.

    0 讨论(0)
  • 2021-02-15 07:11

    I discovered that the issue is in the function:

    - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
    

    There is something wrong with the section indexes algorithm after iOS 7.0, and Obviously it's a framework bug. I ended doing something like this:

    - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView  {
            **if(IS_IOS7 || isSearching)
                return nil;**
            else
                return [self.dictAllKeysAlphabetically allKeys]; 
    }
    

    This is an ugly patch which will remove the letters bar from right side of your screen, but at least your app won't crash.

    0 讨论(0)
  • 2021-02-15 07:14

    I have been experiencing this exact issue. I solved this after days of frustration by using a 3rd party section index view and not using the native sectionIndexTitlesForTableView. Check out CMIndexBar. Super easy, got it up an running in about 5 minutes. Easily customizable. This is what I will be using until Apple addresses this bug and I highly recommend it if you are experiencing this crash.

    0 讨论(0)
  • 2021-02-15 07:15

    The issue seemed to have to do with a reloadData call being attempted from a background thread on a background thread, in my case. I guess the data in the view was inconsistent with the index or something like that.

    Weird how it manifests itself in the form seen in the CoreText library (as seen in the stack trace above) and on iOS 7 only.

    When dispatching the call on the main queue to reload the table view's data, reloading performance improved and I could use the section index again. I haven't had that crash since.

    See if doing that fixes it for you.

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