UITableViewAlertForLayoutOutsideViewHierarchy error: Warning once only (iOS 13 GM)

前端 未结 10 753
说谎
说谎 2020-12-25 12:23

I am getting a strange error with iOS13 when performing a Segue and I can\'t figure out what it means, nor can I find any documentation for this error. The problem is that t

10条回答
  •  臣服心动
    2020-12-25 12:44

    I had the same error on my Project; A tableView with a diffable datasource. Been bugging on it for hours. Problem lies in updating the snapshot, more specifically on a background thread (default). Forcing the update of the datasource on the main thread got rid of the problem! Hope this helps someone out there!

        func updateData(on annotations: [Annotation]) {
            var snapshot = NSDiffableDataSourceSnapshot()
            //Append available sections
            AnnotationType.allCases.forEach { snapshot.appendSections([$0]) }
    
            //Append annotations to their corresponding sections
            annotations.forEach { (annotation) in
                snapshot.appendItems([annotation], toSection: annotation.type as AnnotationType)
            }
    
            //Force the update on the main thread to silence a warning about tableview not being in the hierarchy!
            DispatchQueue.main.async {
                self.dataSource.apply(snapshot, animatingDifferences: true)
            }
        }
    

提交回复
热议问题