'UITabBarItem delegate stops from insertSubview
Have a UITabBar that worked fine until some changes that were needed where I am now loading the controller with the UITabBar as a subview. Loading the controller with the UITabView as a subview has caused the delegate for the UITabBar to no longer function. Walking through the code shows the delegate being set for the UITabView to the controller. Checked that the UITabView is still the top view and it is. User interaction is still active on the page but only UITabBar isn't working. This used to work fine until the insertSubview was used. Here is how things are loaded:
let storyBoard = UIStoryboard(name: "MainStoryBoard", bundle: nil)
let vc = storyBoard.instantiateViewController(withIdentifier:"HomeController") as! T
vc.view.tag = 99
view.insertSubview(vc.view, at: 1)
addChild(vc)
vc.didMove(toParent: self)
In the "HomeController" delegate is set self.tabBar.delegate = self in viewDidLoad. Also in this viewcontroller is the extension on UITabBarDelegate.
extension HomePageViewController: UITabBarDelegate {
func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
print(item)
}
}
Anyone have any ideas of what needs to changed so that the UITabView can work again?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
