情景:
答案 0 :(得分:0)
没有Swift不会自动处理此问题。您必须检查现有的子视图控制器以防止添加重复项。
你可以使用这样的代码:
if let controller = parent.childViewControllers.filter { $0 is CountriesViewController }.first {
// use existing child controller here
}
else {
// create new child controller and add it to parent here
}