小编Mar*_*son的帖子

为什么 iOS 在尝试以相反顺序显示排序结果时会崩溃?

我有一个 SwiftUI 应用程序,可以按部分显示信息。当按下按钮时,我想对节标题以及每个节的内容进行升序或降序排序(即,该按钮反转当前的排序顺序。

按下按钮后,应用程序立即崩溃并出现以下错误。我简化了代码以轻松重现问题。在真实的应用程序中,除非您滚动数据然后排序,否则应用程序不会崩溃。

如何才能在不崩溃的情况下达到预期的结果?任何帮助或指示将不胜感激。

Catalina 10.15.2
Xcode 11.3
iOS 13.3
Run Code Online (Sandbox Code Playgroud)
2020-01-29 22:31:07.837639-0800 sections[33051:9858192] *** Assertion failure in -[_UITableViewUpdateSupport _setupAnimationsForNewlyInsertedCells], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3901.4.2/UITableViewSupport.m:1311
2020-01-29 22:31:07.847803-0800 sections[33051:9858192] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempt to create two animations for cell'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff23c7127e __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff513fbb20 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff23c70ff8 +[NSException raise:format:arguments:] + 88
    3   Foundation                          0x00007fff256e9b51 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
    4   UIKitCore                           0x00007fff482c3979 -[_UITableViewUpdateSupport(Private) _setupAnimationsForNewlyInsertedCells] + 1575
    5 …
Run Code Online (Sandbox Code Playgroud)

ios swiftui

5
推荐指数
1
解决办法
767
查看次数

标签 统计

ios ×1

swiftui ×1