“无效模式‘ kCFRunLoopCommonModes’...”是什么意思?

环境: 版本11.0 beta 3(11M362v)

全文如下:

invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug.
This message will only appear once per execution.
Hello World

此消息仅在我单击连接到某个操作的 UISswitch 按钮时出现; 在这里,打印“ Hello World”。

很明显,这种行为并没有受到影响。

enter image description here

作为比较,我在工具栏中创建了一个 UIBarButtonItem,它运行正常。所以开关按钮有点可疑。

问: 为什么会出现这种情况? 这意味着什么? 补救措施?

25323 次浏览

I had a similar problem: When I got the call-back from the UISwitch, I reloaded the UITableView. I think that the call-back is initiated before the UISwitch finishes changing its context, and reloading the cell in that state creates some conflict.

With that theory, I solved my problem like so: I separated the cells into sections, where the cell with the UISwitch was in its own section. When I got the call-back from the UISwitch, I reloaded all the sections except the section that has the cell with the UISwitch.

Judging from the replies by Apple Developer Relations to this post, this is a bug in UIKit and one that Apple is tracking. Until the bug is fixed, the advice is to treat this as "log noise".

I think it's a warning that Apple should fix it itself. Even in this sample project which is from WWDC19 this problem exists. There is a UISwitch in a cell of a table. When I tap it, the mentioned warning is raised.

So, in my view, it is a bug that Apple should deal with.