-1

I have a UITabBarController linked to 4 UIViewController each embedded in a NavigationViewController.

I need to check if when one of these view controllers is currently selected, and the user clicks the same tab bar item for the same view, it will trigger an unwind segue action.

So I think I need to add a UITabBarControllerDelegate but when I tried to add it to the UITabBarController class in the viewDidLoad() method:

let tabBarDel: UITabBarControllerDelegate = UITabBarControllerDelegate()

I see the following error: 'UITabBarControllerDelegate' cannot be constructed because it has no accessible initializers.

0

2 Answers 2

1

I extended the view controller class with UITabBarControllerDelegate. In the viewDidLoad() method I used self.tabBarController?.delegate = self

0

UITabBarController is a protocol, not a class. You can't instantiate a protocol. You need to create your own implementation of the protocol.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.