diff --git a/DuckDuckGo/BlankSnapshotViewController.swift b/DuckDuckGo/BlankSnapshotViewController.swift index 14ccee9272..ab4c6b2471 100644 --- a/DuckDuckGo/BlankSnapshotViewController.swift +++ b/DuckDuckGo/BlankSnapshotViewController.swift @@ -35,7 +35,7 @@ class BlankSnapshotViewController: UIViewController { let menuButton = MenuButton() - let tabSwitcherButton = TabSwitcherButton() + var tabSwitcherButton: TabSwitcherButton! let appSettings: AppSettings var viewCoordinator: MainViewCoordinator! @@ -54,6 +54,8 @@ class BlankSnapshotViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + tabSwitcherButton = TabSwitcherButton() + viewCoordinator = MainViewFactory.createViewHierarchy(view) if appSettings.currentAddressBarPosition.isBottom { viewCoordinator.moveAddressBarToPosition(.bottom) diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index a17d4fed82..ca18ab0e12 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -136,8 +136,8 @@ class MainViewController: UIViewController { }() weak var tabSwitcherController: TabSwitcherViewController? - let tabSwitcherButton = TabSwitcherButton() - + var tabSwitcherButton: TabSwitcherButton! + /// Do not reference directly, use `presentedMenuButton` let menuButton = MenuButton() var presentedMenuButton: MenuButton { @@ -639,6 +639,7 @@ class MainViewController: UIViewController { } private func initTabButton() { + tabSwitcherButton = TabSwitcherButton() tabSwitcherButton.delegate = self viewCoordinator.toolbarTabSwitcherButton.customView = tabSwitcherButton viewCoordinator.toolbarTabSwitcherButton.isAccessibilityElement = true diff --git a/DuckDuckGo/TabsBarViewController.swift b/DuckDuckGo/TabsBarViewController.swift index ce8e51325e..317efa98a9 100644 --- a/DuckDuckGo/TabsBarViewController.swift +++ b/DuckDuckGo/TabsBarViewController.swift @@ -52,7 +52,7 @@ class TabsBarViewController: UIViewController { weak var delegate: TabsBarDelegate? private weak var tabsModel: TabsModel? - let tabSwitcherButton = TabSwitcherButton() + var tabSwitcherButton: TabSwitcherButton! private let longPressTabGesture = UILongPressGestureRecognizer() private weak var pressedCell: TabsBarCell? @@ -72,6 +72,8 @@ class TabsBarViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + tabSwitcherButton = TabSwitcherButton() + decorate() tabSwitcherButton.delegate = self