My application has two types of login: Vendor or Customer.
Depending on the login, the user will have access to some tabs on the Tab bar controller. Example: - Vendor: Can access Tab 1, Tab 2 and Tab 3 - Customer: Can access Tab 1 and Tab 2
Trying to implement this I made a UITabBarController class (but the line customTabBar.items![2].accessibilityElementsHidden
does not hide the tab):
import UIKit
class CustomTabBarController: UITabBarController {
@IBOutlet weak var customTabBar: UITabBar!
var viewControllerList: [UIViewController]?
override func viewDidLoad() {
super.viewDidLoad()
if SingletonLogin.shared.isVendor {
customTabBar.items![2].accessibilityElementsHidden // Tries to hide Tab 3
customTabBar.items![1].title = "Items"
} else {
customTabBar.items![1].title = "Favorites"
}
}
This class is linked with a Custom Tab Bar Controller on my Storyboard:
I am able to do it programmatically, but then I can't use the views on the storyboard.
I would like to find a way to do this using the storyboard.
class CustomTabBarController: UITabBarController {
@IBOutlet weak var customTabBar: UITabBar!
var viewControllerList: [UIViewController]? // Not required
override func viewDidLoad() {
super.viewDidLoad()
if SingletonLogin.shared.isVendor {
self.viewControllers = [self.viewControllers[0], self.viewControllers[1], self.viewControllers[2]]
} else {
self.viewControllers = [self.viewControllers[0], self.viewControllers[1]]
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.