Searching Google (let alone this forum) returns zero results. Does anyone know what causes this error message and how to resolve it (or whether it's safe to ignore)?
Thanks!
Searching Google (let alone this forum) returns zero results. Does anyone know what causes this error message and how to resolve it (or whether it's safe to ignore)?
Thanks!
Hello, could you please provide more information about what you are doing when you hit this message? Is this Objc, Swift, SwiftUI? Can you share more about the view/APIs you have set up? Is this a message that gets logged or something you see as a warning/error in Xcode?
This is a UIKit app written in Swift.
The issue seems to come up when calling addArrangedSubview(_:) on a UIStackView that is later set as the tableHeaderView or tableFooterView in a UITableView.
If you add the following viewDidLoad() to a plain old UITableViewController, it reproduces the issue in Xcode 14.3.1 on a simulator running iOS 16.4:
override func viewDidLoad() {
super.viewDidLoad()
let headerView = UIStackView(frame: .zero)
headerView.bounds = CGRect(origin: .zero, size: CGSize(width: self.tableView.bounds.width, height: 320))
let label = UILabel(frame: .zero)
headerView.addArrangedSubview(label)
self.tableView.tableHeaderView = headerView
}
I'm having the same problem! At first, I thought it was my header component. But after trying the code @AlchemerFrank mentioned, the same thing is happening to me. Every time I move focus to the next element, I get the following error in the debug console.
Ignoring attempt to add focus items in already-visited container. This can potentially cause infinite recursion. Container: <UIFocusRegionContainer: 0x3000500c0; focusItemContainer: <UILabel: 0x112abd880>; owningEnvironment: <UILabel: 0x112abd880>>
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
let headerView = UIStackView(frame: .zero)
headerView.bounds = CGRect(origin: .zero, size: CGSize(width: self.listComponent.bounds.width, height: 320))
let label = UILabel(frame: .zero)
label.text = "Header"
headerView.addArrangedSubview(label)
self.listComponent.setHeader(headerView)
}
extension List {
@discardableResult
func setHeader(_ headerView: UIView?) -> Self {
tableView.tableHeaderView = headerView
self.headerView = tableView.tableHeaderView
return self
}
}