Dear fellow iOS Developers,
ever since using iOS 10 Beta with Xcode 8 Beta and migrating to Swift 3 I have noticed strange behaviour in my app when using custom UITableViewCells. When I try to dequeue a custom cell in cellForRowAtIndexPath I get a crash with an NSException - except for when I register the cells manually in code. This does not happen with all custom cells though, and I don't know why some cells get registered, and some don't. When I manually register the cells in code, the custom content does not get shown, instead they appear just plain white. This means that Storyboard for some reason cannot register the cells correctly.
- I'm using Prototype Cells.
- The cell identifiers are the same in Storyboard and in cellForRowAtIndexPath.
- I'm using iOS 10 Beta 2 and Xcode 8 Beta 2 (though it already happened with the first betas.)
- I'm using Swift 3.
Anyone here having the same problem? It's totally driving me nuts, and I am running out of ideas on how to fix this issue.
-> This works, but results in blank cells:
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
}
-> This crashes the app:
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 is using a struct where I store all my storyboard identifiers.
Everything worked just fine before updating to the new version of Xcode and Swift 3.
THIS IS THE CRASH LOG:
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)