UITableViewAlertForLayoutOutsideViewHierarchy error: Warning once only (iOS 13 GM)

前端 未结 10 732
说谎
说谎 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:59

    I'm new to Xcode/Swift so this may or may not help anyone. I started getting this error after updating to iOS 13 and Xcode 11 within the app when going back to a list from a detail view.

    I found that I was doing a tableView.reloadRows and tableView.insertRows in the unwind(as suggested by Apple in one of their tutorials)

    @IBAction func unwindToMealList(sender: UIStoryboardSegue) {
        if let sourceViewController = sender.source as? MealViewController, let meal = sourceViewController.meal {
    
            if let selectedIndexPath = tableView.indexPathForSelectedRow {
                // Update an existing meal.
                meals[selectedIndexPath.row] = meal
                tableView.reloadRows(at: [selectedIndexPath], with: .none)
            }
            else {
                // Add a new meal.
                let newIndexPath = IndexPath(row: meals.count, section: 0)
    
                meals.append(meal)
                tableView.insertRows(at: [newIndexPath], with: .automatic)
            }
        }
    }
    
    )
    

    I commented out that section of code and it went away.

    Oddly enough leaving the sort and self.tableView.reloadData() didn't give me the error.

提交回复
热议问题