【发布时间】:2016-05-15 06:42:17
【问题描述】:
当我尝试通过 Xcode6.4 使用 UITableView 时它工作正常,但是当我通过 Xcode 7.1.1 尝试它时它崩溃了。我猜是因为iOS版本。我附上崩溃日志。请建议修复它的最佳方法是什么。我很确定: 1)数据源和代表工作正常。 2) Numberofrows 和 heightOfRow 方法也被调用,但它在 cellForRowAtIndexPath 被调用之前崩溃。
这是日志:
2016-02-05 15:34:27.400 Autograph24[3720:87023] * 断言失败 在-[UITableViewRowData _assertValidIndexPath:allowEmptySection:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.29.5/UITableViewRowData.m:2310 2016-02-05 15:34:27.506 Autograph24[3720:87023] * 终止应用 由于未捕获的异常“NSInternalInconsistencyException”,原因: '无效的索引路径' *** 第一次抛出调用堆栈:( 0 CoreFoundation 0x00000001075c9f45 exceptionPreprocess + 165 1 libobjc.A.dylib
0x0000000107956deb objc_exception_throw + 48 2 核心基础
0x00000001075c9daa +[NSException raise:format:arguments:] + 106 3
基础 0x0000000106e9b5ee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198 4
UIKit 0x0000000108d11412 -[UITableViewRowData _assertValidIndexPath:allowEmptySection:] + 963 5 UIKit 0x0000000108d11465 -[UITableViewRowData ensureHeightsFaultedInForIndexPath:availHeight:edgeInset:scrollPosition:] + 55 6 UIKit 0x0000000108af50c6 -[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:] + 2510 7 UIKit 0x0000000108af59b9 -[UITableView scrollToRowAtIndexPath:atScrollPosition:animated:] + 39 8 Autograph24 0x0000000106b1b2ad -[DashboardVC scrollToToday] + 685 9 Autograph24 0x0000000106b20289 -[DashboardVC changeCalendarStyle] + 313 10 Autograph24 0x0000000106b20144 -[仪表板VC resizeScreenForPortrait] + 788 11 Autograph24
0x0000000106b1f6a0 -[DashboardVC rotateScreen] + 176 12 Autograph24 0x0000000106b15e76 -[DashboardVC viewDidLoad] + 166 13 UIKit
0x0000000108b49cc4-[UIViewController loadViewIfRequired] + 1198 14 UIKit 0x0000000108b4fc7b -[UIViewController __viewWillAppear:] + 120 15 UIKit 0x0000000108b7fa37 -[UINavigationController _startCustomTransition:] + 1203 16 UIKit 0x0000000108b8fcdb -[UINavigationController _startDeferredTransitionIfNeeded:] + 712 17 UIKit 0x0000000108b90cea -[UINavigationController __viewWillLayoutSubviews] + 57 18 UIKit 0x0000000108d36c85 -[UILayoutContainerView layoutSubviews] + 248 19 UIKit 0x0000000108a6be40 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 710 20 QuartzCore 0x000000010736359a -[CALayer layoutSublayers] + 146 21 QuartzCore
0x0000000107357e70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366 22 石英核心 0x0000000107357cee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24 23 QuartzCore 0x000000010734c475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277 24 QuartzCore 0x0000000107379c0a _ZN2CA11Transaction6commitEv + 486 25 石英核心 0x000000010737a37c _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92 26 核心基础 0x00000001074f5947 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23 27 核心基础 0x00000001074f58b7 __CFRunLoopDoObservers + 391 28 CoreFoundation 0x00000001074eb50b __CFRunLoopRun + 1147 29 CoreFoundation
0x00000001074eae08 CFRunLoopRunSpecific + 488 30 图形服务
0x000000010b1b5ad2 GSEventRunModal + 161 31 UIKit
0x00000001089b730d UIApplicationMain + 171 32 Autograph24
0x0000000106b15d9f 主要 + 111 33 libdyld.dylib
0x000000010aac192d 开始 + 1 34 ???
0x0000000000000001 0x0 + 1 ) libc++abi.dylib: 终止于 NSException 类型的未捕获异常
【问题讨论】:
-
你设置 numberOfSection 和 viewForHeader 了吗?
-
崩溃日志中已经说明:- 由于未捕获的异常 'NSInternalInconsistencyException' 导致应用程序终止,原因:'invalid indexPath'。