使用标签栏控制器的相同项目,是否可以根据布尔值 属性 实例化替代视图?

Using the same item of a tab bar controller, is it possible to instantiate alternate views based on the value of a boolean property?

在 2 种用户类型之间,如果任一用户单击选项卡栏控制器的 'Item 1',是否可以根据布尔值 属性 定向到不同的视图控制器那个用户?

当然,根据您的 ID,我认为您的用户类型来自后端。所以你可以做如下的事情。

struct User {
 salesPerson = false
 // other properties
}

let user = User()
if user.salesPerson { // that means salesPerson is true
let vc = UIStoryboard.init(name: "Main", bundle: Bundle.main)
.instantiateViewController(withIdentifier: "SalesPersonViewController") as? SalesPersonViewController
self.navigationController?.pushViewController(vc!, animated: true)
} else { // that means false so you can push other vc
let vc = UIStoryboard.init(name: "Main", bundle: Bundle.main)
.instantiateViewController(withIdentifier: "AdminViewController") as? AdminViewController
self.navigationController?.pushViewController(vc!, animated: true)
}