iOS 7下的UITableView部分索引相关崩溃 [英] UITableView section index related crashes under iOS 7

查看:291
本文介绍了iOS 7下的UITableView部分索引相关崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格视图的简单部分索引,第一次显示正常,但如果发生某些类型的交互,强制重新绘制部分索引,则会崩溃:

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 index, either by:


  1. 通过点击其中一个单元格来推送视图控制器

  2. 点击表格视图标题中的搜索栏或制作它以其他方式响应第一响应者

  3. 转到信息屏幕,然后返回到具有该表视图的视图控制器。

如果我注释掉部分索引(通过在sectionIndexTitlesForTableView中返回nil而不是[self.collat​​ion sectionIndexTitles]),它就可以正常工作。

If I comment out the section index (by returning nil in sectionIndexTitlesForTableView instead of the "[self.collation sectionIndexTitles]"), it works just fine.

它只发生在iOS 7下(因为测试版并没有在7.0.1版本中修复)而且我总是得到以下与CoreText /动画/过渡相关的堆栈跟踪:

It ONLY happens under iOS 7 (since the betas and it's not fixed in the 7.0.1 release) and I always get the following stack trace related to CoreText / animations / transitions:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x000001f0
Triggered by Thread:  0

Thread 0 Crashed:
0   CoreText                        0x31403312 TComponentFont::GetMinSideBearing(CGAffineTransform const&, bool) const + 10
1   CoreText                        0x313f3ada TRun::GetLeftHangersGlyphCountAndWidth(long, unsigned long, TCharStream const&) const + 322
2   CoreText                        0x313f394c TLine::GetLeftHangersGlyphCountAndWidth(unsigned long const*) const + 148
3   CoreText                        0x314025d8 TLine::GetBounds(unsigned long) const + 496
4   CoreText                        0x314023ca CTLineGetBoundsWithOptions + 10
5   UIKit                           0x333641f6 -[UITableViewIndex _cacheAndMeasureTitles] + 758
6   UIKit                           0x33364b8e -[UITableViewIndex sizeThatFits:] + 198
7   UIKit                           0x332f0d62 -[UITableView _updateIndexFrameSuppressingChangeNotification:] + 546
8   UIKit                           0x332f6fe0 -[UITableView setContentInset:] + 268
9   UIKit                           0x332cbaf8 -[UIViewController _setNavigationControllerContentInsetAdjustment:] + 436
10  UIKit                           0x332e432e -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 458
11  UIKit                           0x333af438 __49-[UINavigationController _startCustomTransition:]_block_invoke + 156
12  UIKit                           0x333340b0 -[_UIViewControllerTransitionContext completeTransition:] + 72
13  UIKit                           0x333f4402 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke105 + 450
14  UIKit                           0x332557c6 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 282
15  UIKit                           0x33255412 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 174
16  UIKit                           0x3325532a -[UIViewAnimationState animationDidStop:finished:] + 66
17  QuartzCore                      0x32eadd94 CA::Layer::run_animation_callbacks(void*) + 228
18  libdispatch.dylib               0x3b21cd64 _dispatch_client_callout + 20
19  libdispatch.dylib               0x3b2237bc _dispatch_main_queue_callback_4CF$VARIANT$mp + 264
20  CoreFoundation                  0x30d1480c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 4
21  CoreFoundation                  0x30d130e0 __CFRunLoopRun + 1296
22  CoreFoundation                  0x30c7dcd2 CFRunLoopRunSpecific + 518
23  CoreFoundation                  0x30c7dab6 CFRunLoopRunInMode + 102
24  GraphicsServices                0x356c32d6 GSEventRunModal + 134
25  UIKit                           0x3328211c UIApplicationMain + 1132

我'我几乎排除了与内存相关的问题,因为它发生在空表和6000个单元格中。

I've pretty much ruled out it's memory-related because it happens with an empty table as well as 6000 cells.

这是部分索引的代码:

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
{
    // Don't show section titles when a search is in progress
    if (isFilterInProgress && [self.searchDisplayController isActive]) {
        return nil;
    }

    return  [[self.collation sectionIndexTitles] objectAtIndex:section];
}


- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView 
{
    if(tableView == self.resultsTable){

        // Don't show section titles when a search is in progress
        if (isFilterInProgress && [self.searchDisplayController isActive]) {
            return nil;
        }

        // Don't show section titles when there are filtered results
        if ([self.filteredListContent count] > 0)
            return nil;

        // iOS7 temporary fix for crashes (ICM-9)
        if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")){

            // Crashes under iOS 7 when displayed for a second time!
            return [self.collation sectionIndexTitles];
            //return nil;

        }else{

            return [self.collation sectionIndexTitles];  

        }

    }else return nil;
}


- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index 
{

    // Return correct section
    if(tableView == self.resultsTable){
        return [self.collation sectionForSectionIndexTitleAtIndex:index];
    }else{
        return 0;
    }   
}

是否有其他人遇到类似问题或其他相关问题部分指数?我知道表视图部分索引有一些布局问题以及编辑单元格上的删除按钮,但我不确定这些是否也已修复。我怀疑这只是iOS 7中的一个错误?

Is anyone else having similar issues or any other related to section indices? I knew there were some layouting issues with the table view section index together with delete buttons on editing cells but I'm not sure if those have been fixed either. I suspect it's just a bug in iOS 7?

推荐答案

问题似乎与从一个尝试的reloadData调用有关背景线程背景线程,在我的情况下。我猜视图中的数据与索引或类似的东西不一致。

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.

奇怪的是它如何在CoreText库中看到的形式表现出来(如下所示)上面的堆栈跟踪)和仅在iOS 7上。

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.

这篇关于iOS 7下的UITableView部分索引相关崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆