简体   繁体   English

iOS 11 及更高版本崩溃 -[UIView setDrawsWithVibrantLightMode:]: unrecognized selector sent to instance

[英]iOS 11 and up crashing with -[UIView setDrawsWithVibrantLightMode:]: unrecognized selector sent to instance

I've noticed a significant spike in app crashes on iOS 11 and up with this message.我注意到在 iOS 11 及更高版本上出现此消息的应用程序崩溃显着增加。 This appears to be an internal API that UIKit is calling, the stack trace reveals that it's something inside UITableViewCell :这似乎是UIKit正在调用的内部 API,堆栈跟踪显示它在UITableViewCell内部:

    Application Specific Information:
    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setDrawsWithVibrantLightMode:]: unrecognized selector sent to instance 0x15defa6d0'

    Last Exception Backtrace:
    0   CoreFoundation                       0x0000000181691d04 __exceptionPreprocess + 124
    1   libobjc.A.dylib                      0x00000001808e0528 objc_exception_throw + 52
    2   CoreFoundation                       0x000000018169f1c8 -[NSObject(NSObject) doesNotRecognizeSelector:] + 136
    3   UIKit                                0x000000018ae8711c -[UIResponder doesNotRecognizeSelector:] + 292
    4   CoreFoundation                       0x00000001816976b0 ___forwarding___ + 1376
    5   CoreFoundation                       0x000000018157d01c _CF_forwarding_prep_0 + 88
    6   UIKit                                0x000000018b022d58 -[UITableViewCell _setSeparatorDrawsInVibrantLightMode:] + 216
    7   UIKit                                0x000000018abf5ef0 -[UITableViewCell setSeparatorColor:] + 340
    8   UIKit                                0x000000018abf451c __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 1228
    9   UIKit                                0x000000018aad6e34 +[UIView(Animation) performWithoutAnimation:] + 100
    10  UIKit                                0x000000018abf3f64 -[UITableView _configureCellForDisplay:forIndexPath:] + 268
    11  UIKit                                0x000000018ae03a00 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 844
    12  UIKit                                0x000000018ae03eac -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 76
    13  UIKit                                0x000000018ade39f0 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2136
    14  UIKit                                0x000000018ab99508 -[UITableView layoutSubviews] + 136

I've been unable to reproduce this but it's crashing consistently on a number of user devices and there's no common thread between device or OS version except that it's only occurring on iOS 11 and up.我一直无法重现这个问题,但它在许多用户设备上一直崩溃,并且设备或操作系统版本之间没有共同的线程,除了它只发生在 iOS 11 及更高版本上。

Eventually figured out that this is a bug in UIKit when the Darken Colors setting is enabled under Accessibility settings:最终发现这是在辅助功能设置下启用了深色设置时UIKit的错误:

Settings -> General -> Accessibility -> Increase Contrast -> Darken Colors

If you're experiencing this crash try toggling that setting on/off to reproduce it.如果您遇到此崩溃,请尝试打开/关闭该设置以重现它。

For now we've suppressed this by simply implementing this method as a Void function in an extension:现在我们通过简单地将此方法实现为扩展中的Void函数来抑制这一点:

@available(iOS 11.0, *)
extension UITableViewCell {
  func _setSeparatorDrawsInVibrantLightMode(_ value: Bool) {

  }
}

So UIKit can call it but it just doesn't do anything (and doesn't crash the app).所以UIKit可以调用它,但它什么也不做(并且不会使应用程序崩溃)。

As jwswart told in his answer next code should be added:正如 jwswart 在他的回答中所说,应该添加下一个代码:

@available(iOS 11.0, *)
extension UITableViewCell {
  @objc func _setSeparatorDrawsInVibrantLightMode(_ value: Bool) {

  }
}

But sometimes you receive same error message but for a different problem.但有时您会收到相同的错误消息,但针对不同的问题。 To fix it as well, you should add also:要修复它,您还应该添加:

@available(iOS 11.0, *)
extension UITableView {
  @objc func _setSeparatorsDrawInVibrantLightModeUIAppearance(_ value: Bool) {

  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 -[UIView AdjustedContentInset]:无法识别的选择器已发送到ios 11中的实例 - -[UIView adjustedContentInset]: unrecognized selector sent to instance in ios 11 调用sizeToFit时,ios应用崩溃,无法识别的选择器发送到实例 - ios app crashing with unrecognized selector sent to instance when sizeToFit is called 由于-[UIView _setLayerConfig:],iOS应用程序崩溃:无法识别的选择器发送到实例 - iOS App crashes because of -[UIView _setLayerConfig:]: unrecognized selector sent to instance 无法识别的选择器已发送到实例ios - unrecognized selector sent to instance ios iOS,无法识别的选择器发送到实例? - iOS, unrecognized selector sent to instance? iOS:无法识别的选择器已发送到实例 - iOS: Unrecognized selector sent to instance [UIView setText:]: 无法识别的选择器发送到实例 - [UIView setText:]: unrecognized selector sent to instance - [UIView setHostedGraph:]无法识别的选择器发送到实例 - -[UIView setHostedGraph:] unrecognized selector sent to instance PKReveal Controller UIVIEW无法识别的选择器已发送到实例 - PKReveal Controller UIVIEW unrecognized selector sent to instance [UIView registerClass:forCellReuseIdentifier:]:无法识别的选择器已发送到实例 - [UIView registerClass:forCellReuseIdentifier:]: unrecognized selector sent to instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM