Fix close buttons unnecessarily being added to navigation column
This commit is contained in:
parent
75f0d12c82
commit
c60aa3e3f3
|
@ -273,12 +273,17 @@ private class ColumnView: UIView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func installCloseBarButton(navigationItem: UINavigationItem) {
|
private func installCloseBarButton(navigationItem: UINavigationItem) {
|
||||||
let item = UIBarButtonItem(image: UIImage(systemName: "xmark"), style: .done, target: self, action: #selector(closeNavigationColumn))
|
func makeItem() -> UIBarButtonItem {
|
||||||
item.accessibilityLabel = "Close Column"
|
let item = UIBarButtonItem(image: UIImage(systemName: "xmark"), style: .done, target: self, action: #selector(closeNavigationColumn))
|
||||||
if navigationItem.leftBarButtonItems != nil {
|
item.accessibilityLabel = "Close Column"
|
||||||
navigationItem.leftBarButtonItems!.insert(item, at: 0)
|
return item
|
||||||
|
}
|
||||||
|
if let leftItems = navigationItem.leftBarButtonItems {
|
||||||
|
if !leftItems.contains(where: { $0.action == #selector(closeNavigationColumn) }) {
|
||||||
|
navigationItem.leftBarButtonItems!.insert(makeItem(), at: 0)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
navigationItem.leftBarButtonItems = [item]
|
navigationItem.leftBarButtonItems = [makeItem()]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue