UITableView section index related crashes under iOS 7

后端 未结 4 1648
感动是毒
感动是毒 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: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.

提交回复
热议问题