2016-01-28 116 views
1

我有一个tableview与展开/ collapsable部分。它工作正常的iOS 8,但在iOS的9 reloadSections崩溃这是代码:ReloadSections崩溃:iOS 9

NSRange range = NSMakeRange(selectedSection, 1); [_tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:range] withRowAnimation:UITableViewRowAnimationAutomatic];

我已经看过了这个问题,似乎有些人都遇到过,但没有一个解决方案还没有工作为了我。当然,我可以重新加载表,但这不会给我动画的样子,我只是不希望整个tableview重新加载。这里是(在控制台通过命令bt)我唯一的日志:

thread #1: tid = 0xfecd, 0x25be16aa UIKit__46-[UITableView _updateWithItems:updateSupport:]_block_invoke + 98, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xfffffffc) 

frame #0: 0x25be16aa UIKit__46-[UITableView _updateWithItems:updateSupport:]_block_invoke + 98 
frame #1: 0x25d074fc UIKit__46-[UITableView _updateWithItems:updateSupport:]_block_invoke1011 + 184 
frame #2: 0x25be10b4 UIKit-[UITableView _updateWithItems:updateSupport:] + 2348 
frame #3: 0x25bc5684 UIKit-[UITableView _endCellAnimationsWithContext:] + 10648 
frame #4: 0x25bc2b5a UIKit-[UITableView _updateSections:updateAction:withRowAnimation:headerFooterOnly:] + 434 
frame #5: 0x25bc299e UIKit`-[UITableView reloadSections:withRowAnimation:] + 38 
frame #6: 0x0028d956 MyAPP-[MyView expandCollapseSection:](self=0x16f90170, _cmd=0x0096e193, sender=0x16fec2d0) + 1230 at MyView.m:256 
frame #7: 0x25a09770 UIKit-[UIApplication sendAction:to:from:forEvent:] + 80 
frame #8: 0x25a09700 UIKit-[UIControl sendAction:to:forEvent:] + 64 
frame #9: 0x259f161e UIKit-[UIControl _sendActionsForEvents:withEvent:] + 446 
frame #10: 0x25a09050 UIKit-[UIControl touchesEnded:withEvent:] + 616 
frame #11: 0x259c2fc6 UIKit_UIGestureRecognizerUpdate + 10934 
frame #12: 0x25a01e10 UIKit-[UIWindow _sendGesturesForEvent:] + 904 
frame #13: 0x25a015c2 UIKit-[UIWindow sendEvent:] + 622 
frame #14: 0x259d2118 UIKit-[UIApplication sendEvent:] + 204 
frame #15: 0x259d0756 UIKit_UIApplicationHandleEventQueue + 5134 
frame #16: 0x217fd256 CoreFoundation__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14 
frame #17: 0x217fce46 CoreFoundation__CFRunLoopDoSources0 + 454 
frame #18: 0x217fb1ae CoreFoundation__CFRunLoopRun + 806 
frame #19: 0x2174dbb8 CoreFoundationCFRunLoopRunSpecific + 516 
frame #20: 0x2174d9ac CoreFoundationCFRunLoopRunInMode + 108 
frame #21: 0x229c7af8 GraphicsServicesGSEventRunModal + 160 
frame #22: 0x25a39fb4 UIKitUIApplicationMain + 144 
frame #23: 0x0009a1ec MyAppmain(argc=1, argv=0x0108bb24) + 108 at main.m:17 

我一直在使用的更新区块(beginUpdates)和动画块,但妄图。 任何帮助表示赞赏。

回答

0

尝试封装的部分重载语句中[self.tableview beginUpdates][self.tableview endUpdates]:

[self.tableview beginUpdates] 
NSRange range = NSMakeRange(indexPath.section, 1); 
NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range]; 
[self.tableView reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic]; 
[self.tableview endUpdates] 

希望这将帮助你:)

+0

我试过这个没有任何成功。对不起,我应该在上面提到它。 – user3752049

-1

我写了一个一个工作水龙头扩大tableview部分的小例子,可以在这里找到:https://github.com/CharlesThierry/stackoverflow-35056650

我不能重现你的问题它,但是从点点研究,我做了,它有事情做与不具有行(从this post

你可以尝试从帖子的最后解决方案的部分,如果您尚未:

[self.tableview beginUpdates]

之前添加

if ([self.tableView.dataSource numberOfSectionsInTableView:self.tableView] == 1 && 
    [self.tableView.dataSource tableView:self.tableView numberOfRowsInSection:0] == 0) 
{ 
    [self.tableView reloadData]; 
} 
0

我有同样的问题,但只有iPhone 6和只在某些章节。它与iPhone6 plus一起工作。每个设备都使用.reloadData(),但我想要一个不错的动画。当我将折叠的部分行数设置为1而不是0时,它也可以工作。这个问题与重新加载iOS9中的空白部分有关。 我使用了这个工作,因此它至少是tableview的动画更新。这里的斯威夫特代码:

UIView.transitionWithView(self.yourTableView, 
          duration: 0.35, 
          options: .TransitionCrossDissolve, 
          animations: 
    {() -> Void in 
     self.forecastTableView.reloadData() 
    }, 
          completion: nil);