iOS的10测试版 - 崩溃调用dequeuereusableCellWithIdentifier

问题描述:

亲爱的同学iOS开发,iOS的10测试版 - 崩溃调用dequeuereusableCellWithIdentifier

自从使用的是iOS 10测试在Xcode 8测试版,并迁移到斯威夫特3我使用自定义UITableViewCells时已经注意到在我的应用程序奇怪的行为时。 当我尝试在cellForRowAtIndexPath中取出一个自定义单元格时,我得到一个NSException异常 - 除了当我在代码中手动注册单元格时。尽管这对所有的自定义单元都没有发生,我不知道为什么有些单元格会被注册,有些则不会。 当我手动注册代码中的单元格时,自定义内容不会显示,而是显示为纯白色。 这意味着Storyboard出于某种原因无法正确注册单元格。

  • 我正在使用原型单元格。
  • 单元格标识符在Storyboard和cellForRowAtIndexPath中是相同的。
  • 我使用的是iOS 10 Beta 2和Xcode中8 Beta 2的(尽管它已经与第一测试版发生了。)
  • 我用斯威夫特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和新版本的雨燕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) 
+0

您可以使用cellForRowAtIndexPath函数的代码更新您的文章 – Ludovic

+0

更新了我的文章。 – Valentin

+0

我不明白你为什么要存储很多单元格标识符?你只需要一个 – Ludovic

这个问题可能是由于控制和之间的连接故事板上的变量。请检查插座变量,如果有未使用或不连接的插座变量

+0

尤其适用于桌面单元类上的自定义表格视图单元格及其插座变量的控件。 –