iOS 10测试版-调用dequeuereusableCellWithIdentifier时崩溃
亲爱的iOS开发者们: 自从将iOS 10测试版与Xcode 8测试版结合使用并迁移到Swift 3后,我注意到我的应用程序在使用自定义UITableViewCells时出现了奇怪的行为。 当我试图在cellForRowAtIndexPath中对自定义单元格进行出列时,我会遇到一个NSException崩溃-除非我在代码中手动注册这些单元格。但并非所有自定义单元格都会出现这种情况,我不知道为什么有些单元格会注册,有些则不会。 当我在代码中手动注册单元格时,自定义内容不会显示,而是显示为纯白色。 这意味着故事板由于某些原因无法正确注册单元格iOS 10测试版-调用dequeuereusableCellWithIdentifier时崩溃,ios,swift,uitableview,storyboard,beta,Ios,Swift,Uitableview,Storyboard,Beta,亲爱的iOS开发者们: 自从将iOS 10测试版与Xcode 8测试版结合使用并迁移到Swift 3后,我注意到我的应用程序在使用自定义UITableViewCells时出现了奇怪的行为。 当我试图在cellForRowAtIndexPath中对自定义单元格进行出列时,我会遇到一个NSException崩溃-除非我在代码中手动注册这些单元格。但并非所有自定义单元格都会出现这种情况,我不知道为什么有些单元格会注册,有些则不会。 当我在代码中手动注册单元格时,自定义内容不会显示,而是显示为纯白色。
- 我用的是原型细胞
- 故事板和cellForRowAtIndexPath中的单元标识符相同
- 我使用的是iOS 10 Beta 2和Xcode 8 Beta 2(尽管第一个Beta已经出现了这种情况)
- 我用的是Swift 3
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
tableView.register(ProgressCell.self, forCellReuseIdentifier: Storyboard.progressCell)
let cell = tableView.dequeueReusableCell(withIdentifier: Storyboard.progressCell) as! ProgressCell
**Configuring the cell here**
return cell
}
->这会使应用程序崩溃:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: Storyboard.progressCell) as! ProgressCell
**Configuring the cell here**
return cell
}
Storyboard.progressCell正在使用一个结构,我在其中存储我的所有故事板标识符
在升级到新版本的Xcode和Swift 3之前,一切正常
这是崩溃日志:
2016-07-06 20:47:30.049 MYAPP[59012:8826287] -[UIImageView imageOrientation]: unrecognized selector sent to instance 0x7ff5d361f590
2016-07-06 20:47:30.059 MYAPP[59012:8826287] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView imageOrientation]: unrecognized selector sent to instance 0x7ff5d361f590'
*** First throw call stack:
(
0 CoreFoundation 0x000000010614e9bb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001057a731e objc_exception_throw + 48
2 CoreFoundation 0x00000001061badb4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00000001060d4ee5 ___forwarding___ + 1013
4 CoreFoundation 0x00000001060d4a68 _CF_forwarding_prep_0 + 120
5 UIKit 0x00000001072236a7 -[UIImageView _updateImageViewForOldImage:newImage:] + 358
6 UIKit 0x000000010721edab -[UIImageView setImage:] + 391
7 UIKit 0x00000001073c57f7 -[UITableViewCell setImage:] + 79
8 Foundation 0x00000001052c8b7f -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
9 UIKit 0x00000001070d4195 -[UIView(CALayerDelegate) setValue:forKey:] + 173
10 UIKit 0x000000010740ce72 -[UIRuntimeOutletConnection connect] + 109
11 CoreFoundation 0x00000001060f4bb0 -[NSArray makeObjectsPerformSelector:] + 256
12 UIKit 0x000000010740b7f6 -[UINib instantiateWithOwner:options:] + 1867
13 UIKit 0x0000000107168a0d -[UITableView _dequeueReusableViewOfType:withIdentifier:] + 368
14 UIKit 0x0000000107168f08 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 71
15 MYAPP 0x0000000104f0808a _TTSf4g_g_d___TFC8MYAPP22ProgressViewController9tableViewfTCSo11UITableView12cellForRowAtV10Foundation9IndexPath_CSo15UITableViewCell + 138
16 MYAPP 0x0000000104f0717f _TToFC8MYAPPe22ProgressViewController9tableViewfTCSo11UITableView12cellForRowAtV10Foundation9IndexPath_CSo15UITableViewCell + 63
17 UIKit 0x000000010717c16a -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 746
18 UIKit 0x000000010717c2c6 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
19 UIKit 0x000000010715053e -[UITableView _updateVisibleCellsNow:isRecursive:] + 3295
20 UIKit 0x0000000107185221 -[UITableView _performWithCachedTraitCollection:] + 110
21 UIKit 0x000000010716c1db -[UITableView layoutSubviews] + 222
22 UIKit 0x00000001070d47bf -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 956
23 QuartzCore 0x000000010edca278 -[CALayer layoutSublayers] + 146
24 QuartzCore 0x000000010edbdd3c _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
25 UIKit 0x00000001070c290b -[UIView(Hierarchy) layoutBelowIfNeeded] + 275
26 UIKit 0x00000001071f05ea -[UINavigationController _layoutViewController:] + 1625
27 UIKit 0x00000001071ef418 -[UINavigationController _layoutTopViewController] + 341
28 UIKit 0x00000001071ec811 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 874
29 UIKit 0x00000001074c1278 -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:] + 418
30 UIKit 0x00000001074c15da -[UINavigationTransitionView _cleanupTransition] + 766
31 UIKit 0x000000010709daed -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 222
32 UIKit 0x00000001070995bd +[UIViewAnimationState popAnimationState] + 307
33 UIKit 0x00000001074c0fee -[UINavigationTransitionView transition:fromView:toView:] + 2808
34 UIKit 0x00000001071f1697 -[UINavigationController _startTransition:fromViewController:toViewController:] + 3314
35 UIKit 0x00000001071f1c37 -[UINavigationController _startDeferredTransitionIfNeeded:] + 876
36 UIKit 0x00000001071f2d5d -[UINavigationController __viewWillLayoutSubviews] + 58
37 UIKit 0x00000001073da66f -[UILayoutContainerView layoutSubviews] + 223
38 UIKit 0x00000001070d47bf -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 956
39 QuartzCore 0x000000010edca278 -[CALayer layoutSublayers] + 146
40 QuartzCore 0x000000010edbdd3c _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
41 QuartzCore 0x000000010edbdbba _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
42 QuartzCore 0x000000010ed4be98 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
43 QuartzCore 0x000000010ed78f7f _ZN2CA11Transaction6commitEv + 475
44 QuartzCore 0x000000010ed798eb _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
45 CoreFoundation 0x00000001060f4437 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
46 CoreFoundation 0x00000001060f43a7 __CFRunLoopDoObservers + 391
47 CoreFoundation 0x00000001060d8dfe __CFRunLoopRun + 1198
48 CoreFoundation 0x00000001060d86ed CFRunLoopRunSpecific + 285
49 GraphicsServices 0x000000010abfda75 GSEventRunModal + 161
50 UIKit 0x00000001070123b9 UIApplicationMain + 159
51 MYAPP 0x0000000104eda173 main + 99
52 libdyld.dylib 0x0000000109ad768d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
此问题可能是由于脚本上的控件和变量之间的连接造成的。如果存在未使用或未连接的出口变量,请检查出口变量能否使用cellForRowAtIndexPath函数的代码更新帖子我不明白为什么要存储许多单元格标识符??你只需要一个,我把所有故事板标识符都存储在那里,比如segue标识符和cell标识符。问题是,Interface Builder将我的outlet连接到了错误的类-它将类名更改为我在项目中从未使用过的名称,这就是我的其他cell子类发生崩溃的原因。Valentin,尤其是对于自定义表视图单元格上的控件及其在表视图单元格类上的输出变量。